📜  git stash docs - Shell-Bash (1)

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

Git Stash: Shell-Bash

When working on a Git project, it is common to switch between branches or work on multiple features simultaneously. However, sometimes you may need to put your current work aside temporarily and come back to it later without committing your changes. This is where Git Stash comes in.

What is Git Stash?

Git Stash is a Git command that allows you to save your local changes to a temporary area without committing them to the repository. This allows you to switch to another branch, work on a different feature, or perform other operations without affecting your current work. You can later retrieve your stashed changes and continue working on them.

How to Use Git Stash

To stash your changes, run the following command:

$ git stash save "your stashed message here"

This will save your changes to a temporary area and provide a message for you to identify the stashed changes later.

To view your list of stashes, use the following command:

$ git stash list

This will display a list of all your stashes with their corresponding message and index.

To apply the changes of a specific stash, use the following command:

$ git stash apply <stash_index>

This will apply the changes of the specified stash and leave the stash intact.

You can also choose to delete a stash after applying it with the following command:

$ git stash drop <stash_index>

If you wish to apply and delete a stash in one command, use the following instead:

$ git stash pop <stash_index>
Conclusion

Git Stash is a powerful Git command that can help you save and temporarily set aside your local changes. This can come in handy when working on multiple features or switching between branches. With Git Stash, you can better manage your workflow and avoid the hassle of creating multiple branches.