I'm a regular user of Subversion, exploring workflows offered by Git.
I feel myself rather comfortable with Git's way of managing things but
in Subversion, I often use one certain pattern which I'll explain in a
moment, and it seems to be impossible to do in Git.
I hope you'll explain how to work around this issue of change my
mindset to fit Git's idea.

Suppose I have a line of development.
At some point I fork a new branch off the tip of that line; let's call
that point "B" (for "base").
In this new branch I implement lots of new stuff, and during the
course of the development,
a certain file springs into existence and gets developed over time;
let's call it "file.c".
Let's say the tip of this branch is "X" and it contains the described
file "file.c".
Now I decide I want to start implementing another approach to the
problem being solved in "X",
so I branch another line of development off the commit "B", let's call
it "Y".

The problem is that the file "file.c" found in "X" contains some code
which is somewhat
orthogonal to "X" itself and I would like to use it in my fresh banch
So I want that file to appear in "Y".
Of course, and this is a key point, I want it to retain the whole
history of its development in the branch of its origin, "X".

In Subversion, I'd just `svn copy` it from the URL corresponding to
the branch "X" either to the working directory with checked out tip of
"Y" or to "Y" directly. All the history of that file would be

In Git, I can do
$ git checkout -b Y B
$ git checkout X file.c
$ git add file.c
$ git commit

The problem is that after this, `git log file.c` shows only one commit
which brought the file into the tree. `git log -C --find-copies-
harder` doesn't add anything. So the history is lost.

As git-add can't add a file from an existing commit and you can't
selectively merge just one file
from a branch (well, not without some interactive mode with manual
weeding out unneeded changes) and you can't git-cherry-pick a series
of patches related to just one file in one go,
I see no way to get what I want.

I tried to google this and anything I was able to find was [1] which
references [2].
Both posts actually don't provide any solution.
The latter mentions that one should not "copy the code", but I think
my case is clearly diferent.

Any insights are appreciated.

1. http://markpasc.livejournal.com/186489.html
2. http://www.gelato.unsw.edu.au/archives/git/0612/34518.html

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to