MeltingDog
MeltingDog

Reputation: 15404

Git: branch-x changes have become part of branch-y?

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

Answers (1)

dotnetom
dotnetom

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

Related Questions