Common scenarios for git stash

gti stash temporarily stores the changes of the current branch, then git checkout other branches, git pull l pulls the latest code, then git stash pop restores the local changes to this branch, manually resolve the conflict, and finally git push commits the code.

(1) git stash  save "save message": When performing storage, add remarks to facilitate searching. Only git stash is also possible, but it is not easy to identify when searching.

(2) git stash list   : check which stores are stored in stash

(3) git stash show  : Show what changes have been made, the default show is the first store, if you want to show other stores, add stash@{$num}, such as the second git stash show stash@{1}

(4) git stash show -p  : Display the changes of the first store. If you want to display other stores, command: git stash show stash@{$num} -p, such as the second one: git stash show stash@{1 } -p

(5) git stash apply  : apply a certain storage, but will not delete the storage from the storage list. The first storage is used by default, that is, stash@{0}. If you want to use another one, git stash apply stash@{$ num}, such as the second one: git stash apply stash@{1} 

(6) git stash pop  : command to restore the previously cached working directory, delete the corresponding stash in the cache stack, and apply the corresponding modification to the current working directory. The default is the first stash, that is, stash@{0}, If you want to apply and delete other stash, command: git stash pop stash@{$num}, for example, apply and delete the second one: git stash pop stash@{1}

(7) git stash drop  stash@{$num}: discard stash@{$num} storage, delete this storage from the list

(8) git stash clear :Delete all cached stash

Guess you like

Origin blog.csdn.net/qq_33371766/article/details/111094817