Git stash usage

Source: Internet
Author: User

When the development of a branch is not completed, but also switch to another branch for development, in addition to commit the original branch of the code to change the method, I think git stash is a more convenient choice.

The steps are as follows:

First, add changes to stash. In the original branch git stash save-a "Messeag", a lot of information on the Internet does not add-a This option, I think their code development may be in the original code to modify it. For the development of adding code to new files in the project, the-a option puts the newly added code files into staging area.

Second, the restoration of changes . If you want to restore a recent change,git stash pop , I use this for the most. If there are multiple stash operations, then use git stash list to view the stash listing, select the stash you want to pop, run the command git stash pop [email protected]{id} or git stash apply [email protected]{id} . There is quite a lot of information on the Internet.

Third, delete the stash. git stash drop <[email protected]{id}> If you do not add stash number, the default is to delete the latest, that is, the number 0, plus number is to delete the specified number of stash. git stash clear clears all stash, and the whole world is clean!

Four,git stash pop and git stash apply <[email protected]{id}> difference.

When I used git stash pop and git stash apply several times, I found that the stash list seemed a few more stash than I expected. So I went online to understand the difference between the two commands. The original git stash pop [email protected]{id} command will be executed after the corresponding stash ID is removed from the stash list, and git stash apply [email protected]{i The D} command will continue to save the stash ID. For me with a bit of obsessive-compulsive disorder, there's still a growing number of stale stash IDs, so I'm more used to stash pop commands with git.

Five,git stash clear Delete

Stash save not too much, or you do not know which is which, it is best to clear a clear at any time.
Erase all the records and use them git stash clear .

Git stash usage

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.