git: how to not delete files when rebasing commits with file deletion
- by Benjol
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 :(