git stash

datajcthemax·2023년 6월 13일
0

git/github

목록 보기
17/18

The git stash command allows you to temporarily save changes that you have made to your working directory but do not want to commit yet, so you can work on something else. The command saves your changes (both staged and unstaged) away in a new stash, and then reverts them from your working copy.

For example, if you are in the middle of working on a feature and an urgent bug comes in, you can stash your changes, fix the bug, and then come back to the feature without losing your progress.

Here is how to use git stash:

  1. Stashing Your Changes: Use the git stash command to stash your changes. This will save your changes and revert your working copy to the state of the last commit. You can also include a message with your stash like this: git stash save "your message"

  2. Applying Your Stashed Changes: When you are ready to go back to your changes, you can use the git stash apply command to apply the stashed changes to your working copy. This does not remove the changes from your stash. To apply the changes and remove them from your stash, use git stash pop.

  3. Listing Your Stashes: If you have stashed changes multiple times, you can see a list of your stashes with git stash list.

  4. Removing Stashes: If you want to remove a stash, you can use git stash drop followed by the name of the stash. If you want to remove all stashes, you can use git stash clear.

Remember that git stash is a way to save changes that you do not want to commit yet. If you want to save changes that you are ready to commit, you should use git commit instead.

0개의 댓글