9

I have a large (hundreds of files), horribly disorganized (on the file system that is) Xcode project. I want to move a bunch of files into different folders. I want git to track the move operations, and I want my Xcode project to track the moves as well (just keeping the references intact is enough; I don't need Xcode to rearrange its internal group structure, etc.)

If I drag things around in the Finder, both Xcode and git are in the dark. I have faith that git will figure things out by content when the time comes, but I also notice that there's a difference in the output of git status between doing a git mv and moving the file in the Finder, then adding the deletion and addition operations separately, so I'm assuming there's some difference (even if that difference doesn't end up getting encoded into the content of the commit.) Xcode, on the other hand, is hopeless in the face of this. (You have to manually re-find every single file.)

If I use git mv from the command line, git tracks the move, but I still have to manually reconnect each reference in Xcode (or tear them all out and reimport everything, which is a pain in the ass because many of these files have custom build flags associated with them.)

It appears that there simply isn't a way to cause a file system move from within Xcode.

I've found zerg-xcode and a plug-in for it that claims to sync the file system to mirror the Xcode group structure, but I've not been able to google up anything that goes the other way. I just want a way to move files on the file system and have the two other things (git and Xcode) to keep track of the files across the moves. Is this too much to ask? So far it seems the answer is, "yes".

Yes, I've seen Moving Files into a Real Folder in Xcode I'm asking whether someone's written a script or something that makes this less painful.

Community
  • 1
  • 1
ipmcc
  • 29,581
  • 5
  • 84
  • 147
  • It's not an easy thing to do in my experience, which raises the question: why do you want to rearrange files on the disk? Why not put them in a single directory on disk, and organize in Xcode? Then, rearranging things is trivial (it's also easier to do things like grep). I typically have exactly one directory per xcodeproj (or per xcodeproj/Makefile/vsproj) on multi-platform projects – Rob Napier Nov 10 '13 at 20:03
  • 1
    I *want* them in a single directory on disk. They're *not* right now. – ipmcc Nov 10 '13 at 20:20
  • ah! :D Typically I handle this kind of work by writing scripts to rewrite the project.pbxproj file. Simple search/replace perl scripts actually are pretty safe to run on it (or I manage it in TextWrangler or the like). – Rob Napier Nov 10 '13 at 20:39
  • if you have a repository with file `foo`, `git mv foo bar` is equivalent to `mv foo bar; git rm foo; git add bar`. git has no concept of a move; it figures that out on-the-fly. `git mv` is just shorthand. – strugee Jun 18 '15 at 20:40

1 Answers1

0

Actually, by design, Git doesn't track moves. Git is only about content. If any Git tool tells you there was a move (like git log --follow, it's something that was guessed from content, not from metadata).

So you won't lose information if you move files around with another tool then git add the whole folder.

Nowhere man
  • 5,007
  • 3
  • 28
  • 44