2

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?

Eric
  • 16,003
  • 15
  • 87
  • 139
  • please see my answer below about "creating a **junction** or **hardlink**" - this will allow you to do what you want. – Flak DiNenno Apr 09 '14 at 20:37

2 Answers2

1

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.

ldx.a.ldy.c
  • 687
  • 4
  • 9
  • I can't move the files as there are hundreds of them and I would need to manually readd them to the target. Changing the git directory is possible to do from the command line (http://stackoverflow.com/questions/9797387/how-can-i-git-add-a-file-without-changing-the-current-working-directory) but I can't figure out the command... – Eric May 11 '12 at 16:49
1

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

Community
  • 1
  • 1
Flak DiNenno
  • 2,193
  • 4
  • 30
  • 57