Git Study Notes 1 magic git stash

Source: Internet
Author: User

Http://blog.csdn.net/qinjienj/article/details/7475890

Developers often encounter this situation: it takes a few days to create a new function, and has changed more than a dozen files. Suddenly, a bug needs to be solved urgently, and then a build test group is given. Before the advent of git, manual backup was basically required, which was time-consuming and error-prone.

In short, the GIT stash command is used to help developers temporarily shelve the changes they have made, roll back to the status before the changes, and perform other necessary operations (such as publishing, solving a bug, or branch, and so on. You can reload the changes that were put on hold later. Is it cool?

First, use git add to add all the changes to the staging area.

Git add.

Use git stash to put these changes on hold.

Git stash

At this point, the current work platform will reply to the change. What should I do? 10 thousand words are omitted here.

Need to retrieve the changes that were previously shelved and continue the previous work?

Git stash apply.

You can also use git stash list to view all the shelved versions (it may have been shelved many times, so it is better not to do this, it is easy to confuse)

When a stack is shelved, for example, if you want to retrieve the 2nd stacks, you can use git stash apply stash @ {1}

If you want to retrieve 1st, you can use git stash pop

If you want to delete a stash, git stash drop <ID>

Delete all stash and git stash clear

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.