Be careful with git stash save-a

Source: Internet
Author: User
Tags using git

http://m.blog.csdn.net/article/details?id=26815433

has been using Git stash to temporarily save temporary changes, yesterday found this article git stash command, said to be using Git stash save-a will add the new code file at the same time into the registers, I believe, the results did not expect to bring a pit, want to use Git stash When pop recovers, it prompts

XXXX already exists, no checkout
could not restore untracked files from stash

The most obvious is that the file in the Pod folder prompts this error, and the Pod folder I was ignoring in. Gitignore.

-a denotes all, which is not only to put the newly added code file into the registers, but also to put the files ignored by the. Gitignore into registers. If you want to not affect the files that are ignored, you should use-U to represent untracked files.

http://m.blog.csdn.net/article/details?id=26815433

How to use the git stash command online a lot, I want to record the use of the process I feel useful and useful:

I think git stash is a more convenient option when the development work in one branch is not completed, but you switch to another branch for development, and in addition to the method of making the code changes in the original branch.

The steps are as follows:

One, add changes to stash. In the original branch git stash save-a "Messeag", a lot of information on the Internet without the option of a-a, I think their code development may be in the original code to modify it. For the development of new code files added to the project, the-a option puts the newly added code file into the registers at the same time.

Ii. restoration of changes. If you want to restore a recent change, git stash pop, I use the most. If you have multiple stash operations, view the stash list from Git stash, select the stash you want to pop, run the command git stash pop stash@{id} or git stash apply stash@{id}. There is a lot of information on the Internet.

Third, delete the stash. git stash drop <stash@{id}> If stash number is not added, 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 is to erase all stash, and the whole world is all of a sudden pure.

Four, git stash pop and git stash apply <stash@{id}> difference.

After I used git stash pops and git stash to apply a few times, I found that stash list seems to be a few more stash than I expected. So I went online to understand the difference between the two orders. The original git stash pop stash@{id} command will remove the corresponding Stash ID from stash list after execution, and the Git stash apply Stash@{id} command will continue to save the stash ID. For me with a bit of obsessive-compulsive disorder, it's not as if more and more old stash IDs still exist, so I'm more used to using Git stash pop commands.

2/F Zhixinghe1

You this temporary save with a really pit ah, the unchanged also added to the temporary deposit, and so I switch the branch back has not been able to restore changes 2016-05-24 16:23 reply imolable

Reply zhixinghe1: Me too, pit dead me; should be git stash save-u 2016-08-08 20:39

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.