I am trying to merge different versions of the same file in git for one of my projects. The only way git will let me do this is by branching the repo, modifying the file, and then pulling the branch into my master. The only problem is, my project contains 100's of files and I only need this one. Is there any way to pull from a branch containing only this file? Every time I try to do this, it deletes all of the other files. Is there some other way I can accomplish the base task at hand?
+5
A:
The only problem is, my project contains 100's of files and I only need this one.
This shouldn't be a problem. Go ahead and
- Clone the entire branch with 100's of files.
- Modify the single file of interest.
- Commit the new branch (with 100's of files, only one of which has changed).
- Pull the new branch into the old one, merging on the way.
It sounds horrible, but git does this sort of thing very efficiently.
Norman Ramsey
2009-05-02 00:38:07
+1
A:
I'm not sure of what are you trying to accomplish, but it looks like your fears are based in the idea that if you branch all your files, you'll end up with many un-needed copies of the files in your repo. That's not true, as git internally is extremely efficient. So, branch without any fear, git takes care of the rest.
Doppelganger
2009-05-03 05:05:34