Reputation: 28912
I have two branches that I'm working on: dev
, and test
. I made some changes in test
, and wanted to merge those into dev
. However, I only wanted to merge SOME changes to dev
, not the whole diff.
I could not cherry-pick commits, because that would have been too many.
What I did instead, was to checkout on dev
, then merge test
locally. I then staged and committed only the changes that I wanted to merge. The others, I discarded (which did not affect the test
branch).
Now I am ready to merge the other changes (that I previously discarded on local dev
, but which are still in test
) from test
into dev
. When I checkout on dev
again and then try to merge test
into dev
, it says "Already up to date".
I checked the source code: when checking out on test
, I see the method I've added. When switching to dev
instead, the method is not there (because it's not merged yet). When I switch back to test
, the changes are there again.
How is it possible that the merge does not include all changes I made?
Edit
I followed @Ôrel's advice from the comments and merged dev → test
, then test → dev
and now the previously discarded changes are gone from both dev
and test
. How do I restore them?
Upvotes: 1
Views: 184
Reputation: 1324318
What I did instead, was to checkout on dev, then merge test locally. I then staged and committed only the changes that I wanted to merge.
The idea would be, after staging, and before committing, to stash the rest (the part not staged).
See "Stashing only un-staged changes in Git"
git stash save --keep-index
That way, when you are "ready to merge the other changes (that I previously discarded on local dev
, but which are still in test
)", instead of merging again (which was already done), you stash pop
it.
That will apply all those other changes to your dev
branch.
Upvotes: 1