git: how to not delete files when rebasing commits with file deletion
Posted
by Benjol
on Stack Overflow
See other posts from Stack Overflow
or by Benjol
Published on 2010-03-19T09:54:02Z
Indexed on
2010/03/23
10:53 UTC
Read the original article
Hit count: 357
I have a branch that I would like to rebase onto the lastest commit on my master. The problem is that one of the intervening commits on master was to delete and ignore a particular set of files (see this question).
If I just do a straight rebase, those files will get deleted again. Is there anyway of doing this, inside git, rather than copying all the files out by hand, then copying them back in again afterwards?
Or should I do something like create a new branch off master, then merge in just the commits from the old branch?
Attempts ascii art:
master branch
| w work in progress on branch
C | committed further changes on master
| |
B / committed delete/ignore files on master
| 2 committed changes on branch
| /
A / committed changes on master which I now need to get branch working
| 1 committed changes on branch
0___/ created branch
(Doing the art, I realise that I could just rebase branch from A, then merge when I've finished, but I'd still like to know if there's a way to do this 'properly')
UPDATE Warning to anyone trying this. The solution proposed here is fine, but when you checkout master again, the B commit will be re-applied, and you lose all your files again :(
© Stack Overflow or respective owner