git stash command

 

Stash English meaning: storage

 

scenes to be used:

The current workspace content has been modified, but not completed. At this point there is an urgent bug in the project that needs to be fixed immediately. However, we have not completed the modification and do not want to submit the current modification, which can reduce unnecessary commit records.

However, if you don't commit, there is no way to checkout to the previous branch. At this point, using Git Stash is equivalent to backing up the workspace. Then modify it in Checkout to save the current workspace and restore it in time.

 

Order:

git stash: Back up the content of the current workspace, read the relevant content from the most recent commit, and make the workspace consistent with the content of the last commit.

       At the same time, save the current workspace contents to the Git stack.
git stash apply: Read the last saved content from the Git stack and restore the relevant content of the workspace. But will not remove the stash from the top of the stack
git stash list: is a list that shows all backups in the Git stack
git stash clear: clears the Git stack

 

Replenish:

The git stash apply option only tries to apply the stash's work - the stash's contents are still on the stack. To remove it, run  git stash drop, adding the name of the stash you wish to remove:

 

 

git stash pop = git stash apply + 从栈顶移除储藏

 

This is a great shortcut to restore stash work and then continue working on a new branch

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325219859&siteId=291194637