Reputation: 15404
I don't know how it happened, but I am on a 'branch-x' and the files I have changed belong to `branch-y'.
I cannot git checkout branch-Y
because the I have un-committed changes and I don't want to commit them in branch-x.
How can I return to branch-y with my changes intact?
Upvotes: 0
Views: 27
Reputation: 24901
You could stash your changes:
git stash
Then checkout the correct branch:
git checkout branch-Y
And then unstash the changes in the correct branch:
git stash pop
Depending on what types of changes you made in your initial branch, you might need to use additional switches on stash
command (e.g. --include-untracked
). You can read more about stash
command in Git docs.
Upvotes: 1