The use of Git stash

Source: Internet
Author: User
Tags using git

When you use Git svn, when you commit a record, some of the file changes do not require a commit.

When Git svn dcommit to SVN, the local directory must be saved as clean. So we need to do stash, and then in Dcommit

After Dcommit, you need to stash aply in git

have been using git stash and git stash apply

But there has been no in-depth research, today found that git stash is going to overwrite the previous stash

git stash--help View Help manual

Or check the website's Help manual for more details https://git-scm.com/book/en/v1/Git-Tools-Stashing

Use git stash if you want to record the current state of the working directory and the index, but want to go BA CK to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

The modifications stashed away by this command can is listed with git stash list, inspected with git stash sh ow, and restored (potentially on top of a different commits) with git stash apply. Calling git stash without any arguments are equivalent to git stash save. A stash is by default listed as "WIP on branchname ...", but can give a more descriptive message on the command Line when you create one.

The latest stash you created are stored in Refs/stash; Older stashes is found in the reflog of this reference and can be named using the usual Reflog syntax (e.g. [email PR OTECTED]{0} is the most recently created stash, [e-mail Protected]{1} is the one before it,[email protect Ed]{2.hours.ago} is also possible).

git stash List

View all previously cached stash

$ git Stash list
[Email protected] {0}: WIP on temp:36b0f5f Delete Extra code in Hsdataframemanager class//second stash, overwrite first "git stash apply, only this time, last time not appear"
[Email protected] {1}: WIP on temp:36b0f5f Delete Extra code in Hsdataframemanager class//First time stash
[Email protected] {2}: The message type is printed when the WIP on Temp:c723e17 receives the message, if there is a message inside
[Email protected] {3}: When the WIP on TEMP:18FA2A3 connects the Communication module, the window handle of the main form needs to be passed to the communication

Temp is the name of the branch

The No. 0 and 1th though look exactly the same but are actually different

Git stash Show

View one of the stash in the list

$ git stash show [email protected]{0}
Zbmyun/sourcecode/zitakerhs/zitaker/systemconfig.ini | 2 +-
1 file changed, 1 insertion (+), 1 deletion (-)

$ git stash show [email protected]{1}
Zbmyun/sourcecode/zitakerhs/zitaker/ui/main.cs | 2 +-
Zbmyun/sourcecode/zitakerhs/zitaker/zbmstorage_component.ini | 2 +-
2 files changed, 2 insertions (+), 2 deletions (-)

git stash Apply

Can apply the specified stash, if you do not specify, the default to apply the last stash

If you want to apply one of the older stashes, you can specify it by naming it, like this: git stash apply [email protected]{2} .

If you don ' t specify a stash, Git assumes the most recent stash and tries to apply it:

The use of Git stash

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.