![]() ![]() Note that git stash pop automatically invokes git stash drop, even if the result of the git stash apply is a mess, you've lost your temporary commits if you pop but not if you apply. The git stash apply step essentially (though it's more complicated than this) cherry-picks the commit that git stash made, wherever you are now: so this is like cherry-picking the commit you made on tempbranch. That leaves the problem of deleting the non-branch when you're done with it, so git stash drop deletes the unnamed non-branch that holds the commits. The effect is the same as when you make the temporary branch. What git stash does is make a commit (well, actually two commits) that are not on any branch. $ git stash drop # "git stash pop" means "apply and then auto-drop" $ git stash apply # or even "git stash pop" but I prefer "apply" Now you can git checkout whatever you like, and the commit you made on tempbranch is permanently stored in your repository (well, permanent unless/until you delete the name tempbranch), which enables you to copy stuff from it whenever you want. ![]() The git commit then creates a new commit on this temporary branch: o-o-o <- v4.1.0-rc12 branch This (the -b tempbranch) creates a new, temporary branch pointing to the commit at which you detached your HEAD earlier. Method 2 ( avi's answer): $ git checkout -b tempbranch If the git checkout step succeeds, this is by far the easiest way to deal with it all. The git checkout step will succeed, and carry your changes along, if it can. This might not work, because the git checkout step will refuse to switch to the branch, if (and only if) said switching will wipe out the changes you've already made. Method 1: $ git checkout v4.1.0-rc12 branch ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |