Git stash save progress

Git stash save progress

git stashIt is used to save the current working directory and the state of the temporary storage area, and return to a clean dry workspace. What does it mean? for example

If you are selflessly writing your beautiful code on a certain branch, a friend asks you to look at a certain problem on other branches, and your code is only half written and you don’t want to upload it to the remote end, and you can’t Discard, then you can choose to temporarily save all current modifications.

As follows, I added the file A6.txt in the workspace
insert image description here
and executed it first: git add .Add all the modifications
and then execute: git stash save "A6.txt" The "A6.txt" in the command is a comment, which is convenient for future viewing

At this time, I am looking at the work area
insert image description here
. There is no A6.txt in the work area. A6.txt has been saved, and the work area has been cleaned up, that is, it has been restored to the state before it was modified. Now you can add
new ones with confidence. file or switch to another branch to do other work

I just saved the modification of A6.txt, I added A7.txt in the current workspace, executed stash again
and then added A8.txt and executed stash again

At this time, I want to check all the progress I have saved, and execute the command: git stash list
insert image description here
You can see that there are a total of three stack data, the first saved "A6.txt" is at the bottom of the stack, and the last one is at the top of the stack

Now I want to restore the modification of A7.txt to the workspace, and I can see that the save of "A7.txt" is
executed at index = 1:git stash apply stash@{1}

To delete a saved record
Execute:git stash apply stash@{1}

Restoring saved records can also be executed: git stash poprestore stash@{0}
git stash pop= git stash apply stash@{0}+ git stash apply stash@{1}
, that is, restore the 0th and delete

You can also use to git stash pop stash@{1}specify which one to save and delete

Guess you like

Origin blog.csdn.net/LIQIANGEASTSUN/article/details/124630481