Git stash Recovery

Source: Internet
Author: User

This afternoon in the use of GIT command code management, because of their own negligence of the work of the day to lose the results of their own, this is also a terrible, scared the baby. Really, I believe that the code lost friends must be able to understand my mood, can not understand my mood that I wish you also lost code, so you can deeply appreciate my mood. Hey, then calm down for two seconds, mom eggs, can not be so recognized planted it, I do not want to write again that disgusting UI also have some page logic! So, turn on Baidu asked the degree Niang! Hey, don't say, it really made me find it! Suddenly a kind of clear clouds to see the daylight, keep the clouds open to see the mood of the moon. So close-up this blog hope that everyone with me for the ring, do not because their negligence caused unnecessary trouble, even if the mistake has to believe there must be any way to solve! Right! That's it!
First, let me tell you how I dropped the code:
1.git Stash will write the file staging buffer
2. Git pull origin develop download the latest code from the develop branch
3. Find no conflict, then prepare Git stash pop
4. In Git stash pop, I found a file changed, then ready to continue git stash and then drop a file
5. Yes! You're not mistaken! This is it! I'm calling the wrong git stash to git status!. And then! Direct git stash drop [email protected]{0} then git stash pop! And then! Right!
No, then!
6. The mistake just happened, today just wrote a day of code AH, I gather! No way! No, it's dry! Open degrees Niang, ah, don't say, also really someone solved this problem, suddenly ... Ecstatic road, put it!
7. OK, now tell the Method! Use the following command to retrieve the discard code!
8. First Git fsck--lost-found this is to look at some of your recent deleted commits.
Then find the ID that you successfully deleted when you just git stash drop [email protected]{0}. For example:
Dropped [Email protected]{0} (e2c07caec2b995ba75ce1abd15796c6f1686d532)
Then copy e2c07caec2b995ba75ce1abd15796c6f1686d532 to find the deleted commit ID listed by the git fsck--lost-found,
If there is a congratulations, you can get one step back, you may first use
Git show e2c07caec2b995ba75ce1abd15796c6f1686d532 to see if you've discarded the change file,
If so, direct git merge e2c07caec2b995ba75ce1abd15796c6f1686d532 can be retrieved!
Then think of the fact that this lost file is not a good thing, fully show the strong git, but also get to the new skills, simply awesome!
But still advise everyone, can not make mistakes try not to make mistakes, in case of mistakes too hard, can not be really able to correct the mistakes back.

Git stash Recovery

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.