# Unstage everything (warning: this leaves files with conflicts in your tree)git reset
# Add the things you *do* want to commit heregit add -p # or maybe git add -igit commit
# The stash still exists; pop only throws it away if it applied cleanlygit checkout original-branchgit stash pop
# Add the changes meant for this branchgit add -pgit commit
# And throw away the restgit reset --hard
或者,如果您提前意识到这将发生,只需提交属于当前分支的内容。您可以随时回来修改该提交:
git add -pgit commitgit stashgit checkout other-branchgit stash pop