Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Git staging workspace stash

Shulou Source: shulou.com Published: 2022-06-03 05:32:24 10月14日 Update

Git version 1.9.6 of this article

Git name stash: helps developers to temporarily shelve the changes they have made, go back to the state before the changes, do other necessary actions (such as resolving a bug, etc.), and reload the changes that were shelved before the bug is resolved.

You can think of performing a stash action as temporarily saving the current commit state to a space (stack memory)

Example:

You can see that the stash action returns the state to the unmodified state.

1. Main command

Git stash # throw into the staging area git stash list # list all the data in the staging area git stash pop # remove the last staging state of the staging area (stack memory, first in, first out) followed by the selected record @ {n} git stash apply # fetching the last staging state of the storage area But the stash record does not remove git stash clear # empty the stash record

Example: modify the local code, add it to the staging area, save the modified code to stash, restore it to the unmodified, modify the code, and then submit it; then take out the record of the temporary storage area, and submit it again after the modification is completed

$cat hello.rb$ git status-s $echo "stash 1" > > hello.rb$ git status-s $git stash$ git stash list$ git stash pop

Finally, the conflict is displayed. Forget it, explain the function of stash first, and leave the later branches to solve the conflict problem.

Tags: Status memory memory actions examples conflicts necessary personnel advanced again branches functions names commands clarity version space data questions help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Microsoft vpn Apple