Here's the situation. I'm working on the master
branch. I create file1 and commit. I create file2 and commit. Whoops. I may want to use file2, someday, but it's definitely not something that should be put in the master branch. So that I don't lose file2 I use
git checkout head~1
git branch new-branch
git checkout new-branch
so that I can continue developing. I add file3 to new-branch
. If you've been paying attention, I've got two branches, master
that contains "file1" and "file2" and new-branch
that contains "file1" and "file3".
Now is the time to get the changes I've made back into the master branch. What's the best way to do this? I definitely want the head of the master
branch to point at the files as they appear in new-branch
, but I also don't want to lose the work I've done in file2 by doing a reset, in case I want to use it.
Keep in mind this is a simplification. Instead of just three files, I've got a dozen files with tens of lines of code being changed all over the place all with multiple commits. I certainly hope the solution isn't to do a file-by-file merge/checkout, because that would be a huge pain.
Any ideas?