I had branch A that contained a lot of code and to facilitate merging it, I had to scrape off one big feature - that is, I created a commit deleting some of the new files I created. Thus creating branch B. B got merged to develop, and develop branch piled up some more changes.
Now I want to revisit branch A and merge develop into it. Scraping off was in a single commit. So I would like to
git fetch origin develop
B = A + (deleting commit)
develop = B + commit1 + commit2 + ... + commit[n]
A' = develop - deleting commit
git pull origin develop & git stash pop
Let's say that you have branches
develop in your local git repository. In order to have
develop contain all commits except the large-scale deleting commit, do the following:
git checkout develop git rebase -i A
You will then get a screen that gives you a list of all your commits since the head of branch
A. Delete the line with the commit you don't want, and then save the file (usually the interface is in
vi, so entering
:wq will save and quit. Check out
vi documentation for more details). Once you've done that, the
develop branch will now have all the commits except the big deletion. Don't worry, though, because
B will still have the delete commit, and you can always go back to it by checking out branch
B if you want.
Caveats: you may end up with some conflict or other as a result of doing these operations. Also, there is no guarantee that you code will actually work; git is a text tool, not a "code" tool per-se.