📜  git stash history - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:41:27.864000             🧑  作者: Mango

Git Stash History - Shell/Bash

If you're a programmer who uses Git for version control, you've probably encountered situations where you need to temporarily save your current work without committing it. This is where the git stash command comes in handy.

However, if you stash your changes frequently, it can be difficult to keep track of what you stashed and when. This is where the git stash list and git stash show commands can help.

git stash list

The git stash list command will display a list of all stashes you've created, along with a message and the commit SHA that the stash was based on.

$ git stash list
stash@{0}: WIP on my-feature: 3e2f9ac Add new feature
stash@{1}: WIP on my-feature: 3e2f9ac Fix bug
git stash show

The git stash show command is used to view the changes that were stashed away in a specific stash. By default, it will show you the most recent stash. If you want to view a specific stash, you can pass in its reference, like so:

$ git stash show stash@{1}

This will display a diff of the changes that were stashed away in the second-most recent stash.

Conclusion

Using git stash is a useful tool for temporarily saving your work without committing it. However, it can be difficult to keep track of your stashes over time. The git stash list and git stash show commands can help you manage your stashes and keep them organized.