git stash command to use

Comment: If you used Git for some time, you may be used Git stash command. Git It is one of the most useful features.

  • Git stash save
  • Git stash list
  • Git stash apply
  • Git stash pop
  • Git stash show
  • Git stash branch <name>
  • Git stash clear
  • Git stash drop

 

1. Git stash save

This command is similar to Git stash. However, this command can have some options. I'll be here to discuss some of the important options.

Git stash with message

git stash save “Your stash message”

 

The above command will store up messages. We will see this useful.

No trace of file storage

You can also store files there is no trace.

git stash save -u
or
git stash save --include-untracked

 

2. Git stash list

Before discussing this command, let me tell you git stash of works.
When you enter Git stash or Git stash save, Git creates a Git commit objects with a name, and then save to your warehouse.
This means that you can view your store list at any time.

git stash list

The effect is something like this:

 

 

You can view a list stash created. Recent stash will be on top.
You can see the top piece has a custom message (via Git stash sava "message" command is generated).

3. Git stash apply

This command will work the top of the stack stash apply to the warehouse. This embodiment is stash @ {0}.

You can also stash id will be applied to a stash warehouse:

git stash apply stash@{1}

4. Git stash pop

This command and stash apply very similar, but it will remove the stash in the application to the warehouse after.

E.g:

 

 

You can see the top of the stash is deleted, stash @ {0} into a previous stash.

Similarly, you can pop a stash through specific stash id.

git stash pop stash@{1}

5. Git stash show

This command displays the stash differences are summarized. This command only consider the most recent stash and compare.

 

 

If you want to see a complete difference, can be used:

git stash show -p

And other similar commands, you can view a summary of the differences through a stash stash id:

git stash show stash@{1}

6. Git stash branch <name>

This command creates a new branch according to the most recent stash, and then delete the most recent stash (and stash pop the same).

If you need a stash, you can specify stash id.

git stash branch <name> stash@{1}

When a conflict occurs after you apply the stash to the latest version of a branch, this command can be useful.

7. Git stash clear

This command deletes all the stash warehouse created. There may not be recovered.

8. Git stash drop

This command removes the work stack recent stash. But be careful to use, it may be difficult to restore.
You can declare stash id.

git stash drop stash@{1}

链接:https://www.jianshu.com/p/471c9537f45a

Guess you like

Origin www.cnblogs.com/yazhong-java/p/11725905.html