Xcode git add file not in current directory - xcode

I'm using Xcode 4's built-in Git functionality, and I am pushing my commits to a remote repository.
However, the code files are in one directory (~/users/me/projects/theproject) and the images are in a second, separate directory. (~/dropbox/projects/theproject). Xcode thus allows me to add, commit, and push files that I place in the first directory, but not in the second one. If I right-click one of files, then do Source Control -> Add, it's greyed out.
How can I add the files in the second directory in the remote repository? Is it possible to do it within Xcode? If not, what would be the git command?

Files in a single git repository need to be part of the same directory tree (that is, they all need to be located somewhere underneath the directory containing the .git directory). If you were to move your images from ~/dropbox/... into ~/users/me/projects/theproject, you would be able to add them to the repository.
Alternatively, you could create a separate repository inside your dropbox folder and use that just for the images.

I do this exact thing by creating a junction or hardlink (see below) to my "directory that's outside of the tree" so that it appears to be mounted inside the directory hierarchy where my .git folder/repo sits.
like so:
\(root of project) <------ \real_images_folder
|-- .git |
|-- htdocs |
|-- images <------junction---
see my answer here for details on how to create a junction: https://superuser.com/questions/455853/can-i-delete-the-the-folder-c-programdata-package-cache?answertab=active#tab-top

Related

New files aren't showing up only folders

I'm relatively new to git. I'm using:
git version 1.8.1.msysgit.1
Powershell & Poshgit
I've added one new folder and one new file to my repository. When i do a git status i see the folder but not the file. Why?
In the untracked folder you see there is 1 .sql file and yes i'm sure its not in .gitignore (i've changed .sql files recently and they were tracked).
If i do a git add . will the file that is not shown be added?
Update:
I just had to add the directory and the file automatically shows up. I'm assuming if i had multiple files all of them whould show up. See the command i executed below:
git status is reporting that you have an entire directory without any files that you have git added. As soon as you git add one of the files inside the directory, it will list them.
That's a simplification of git. It knows that it doesn't track any file in that folder, so it just shows the folder name instead of all files it contains.

When I try to drag and drop a folder which contains a git repository (which is a submodule at the moment) it says "Can't drop folder here..."

In the git-windows-interface when I drag and drop a repository it says: "Can't drop folder, You can only drop one folder without git repository with the app at this time. Dropping a single folder will allow you create a new Git repository in that location...".
How should I add a git repository to the git-windows-interface?
thanks
You can try and make GitHub for Windows detect your repo, by modifying the local path(s) it scans.
That would avoid trying that "drag and drop feature" which might not work in your case (being a submodule, which is by nature a nested git repo).
If it isn't possible to change that path, at least try and copy that repo in %HOME%\My Documents (HOME being set by the portable git within GitHub for Windows, C:\User\login on W7+, C:\Document and Settings\Login on WXp).
Then a local scan will detect it.
I was getting the same error. I had been trying to drag in the hidden .Git folder. Instead, drag in the folder above, which contains the .Git folder.
This worked for me:
Rename the ".git" folder to ".git_back"
Create a new git repo in the same folder so the new ".git" folder is in the same folder as the old one.
Close github for windows, delete the new .git folder and rename the old one back to ".git"
Open github for windows again, and it will see the old ".git" folder.

Changed folder structure in Xcode Project not reflected in Git Repository

I have an Xcode project that is under version control. I've grouped the classes in the project navigator into folders based on what the classes do (eg. Models, Views, Controllers, etc.). However, these folder structures seem local to my machine and it is not reflected in my own local git repository, or if I do a git pull from another machine, the folders that I've created or organized my classes into don't appear. So, How do you get the changes you make (organizing the classes into folders) to reflect in your local and remote repository?
Try this
# modified, new and deleted files
git add -A
ref
I found that the adding a folder or directory manually inside the local repository to work for me. Create the folder in the repository,git add folder_name/ to actually track and add it to the repo. The files then can be moved into this folder. Depending on how you move it, you may need to do git rm <file_name> and git add </folder_name/file_name>.

Copy new (changed) files into repository

I have a magento project that I'm managing under subversion version control.
I want to install a module that I downloaded which modifies some core files that are already under svn.
When I copy the new files over the existing managed ones, the repo becomes 'obstructed':
svn: Directory '/foo/app/.svn' containing working copy admin area is missing
What's the proper way to manage bringing in code from outside the repo?
Just make sure not to delete any .svn directory when you copy the new files into your working copy (unless of course you want to delete the repository containing this .svn directory). A simple way to do that is to keep all the directories as is, and only delete and update files.
Alternatively, use SVN 1.7, which uses a single .svn directory at the root of the project instead of a .svn directory in every directory of the project.

TortoiseHg change default .hg folder location

Is it recommend to change the default .hg folder location to a central place? Instead of having the .hg folder stored under working directory. Since I have accidentally shift-deleted the working directory and lost all commit history.
Is there any way to change the default .hg folder location in TortoiseHg?
Or any recommendation on backing up the repo? And how?
AFAIK, changing the location of the .hg folder is not possible. The presence of a .hg folder indicates that a given folder is a HG repository.
Even if it was possible to move the .hg folder itself to another location, there would still have to be some information in your working folder where your actual .hg folder is. So if you would accidentally delete your working folder, you'd also lose the path to the real .hg folder. Same problem :-)
Backing up a repo is easy in distributed version control systems like HG.
Make a clone somewhere (on a server in your network that's backed up regularly, or if you're at home, use a Bitbucket account) and push to it regularly.
I can think of two possible solutions, one I recommend, and one I don't.
The solution I don't recommend relies on your file system having Hard Links. When you create a new project, you could move the .hg directory to somewhere else on the file system, and set up a hard link to it in your working directory. You then essentially have two references on the file system to the same .hg directory, so if you delete one it will still exist.
I have done similar things on my gaming PC to have all savegames stored in subdirectories of a single \savegame directory.
However, a much better solution, and one that I would definitely recommend is as follows:
Have a directory (for example C:\HG) in which all "base" repositories sit. These are not working repositories, and would not have a working directory other than "null". When you create a new project, your first step would be to create a new empty repository in this base area:
hg init C:\HG\myNewProject
You now don't need to touch that repository other than to back it up (I use SkyDrive).
Then in the place you do all your work, you create a clone of that repository:
cd C:\WhereIWork\Projects
hg clone C:\HG\myNewProject myNewProject
Creating the clone automatically creates a link between your working repository and the one in C:\HG : any work you do should be regularly committed and pushed.
And there you have it - a backup that you never need to touch unless you delete your working directory by accident and need to re-clone.

Resources