TIL how to restore deleted branch in git and some comprehenses of `git stash`
Learned how to restore deleted branch in git:
-
Find the SHA1 for the commit at the tip of deleted branch running
git reflog --no-abbrev
; -
Recreate branch running
git checkout -b <branch> <sha>
.
Learned some comprehenses of git stash
:
-
git stash save “Your stash message”
allow give message to your stash -
git stash save -u
orgit stash save --include-untracked
stashes untracked files -
git stash apply stash@{1}
applies specific stash -
git stash pop
applies the most recent stash and removes it. Could also be run with specific stashgit stash pop stash@{1}
-
git stash show
shows summary of stash diffs.git stash show -p
shows full diff. Could be run with specific stashgit stash show stash@{1}
. -
git stash branch <name> stash@{1}
creates a new branch with the latest stash, and then deletes the latest stash (likestash pop
). -
git stash clear
removes all sashes in repo. -
git stash drop
removes most top stash without applying it.git stash drop stash@{1}
removes specific stash.