Git prompts at merge that (no branch) almost lost data, and then retrieved

Source: Internet
Author: User

My situation is: after I have changed a lot of things, I quickly submitted it, but I did ignore it. I didn't submit it under any branch at the time. When I finish submitting it, then I went to eclipse to check that all the code I changed was gone. I was particularly scared. My colleague said that I had to redo it, and I didn't give up. I went on to Baidu and found a friend who encountered the same problem as me. So I recovered the lost file.

The original text is as follows:

Because there is a conflict with the remote server, it is actually done on (no branch) when resolving the conflict.

After a period of modification, I suddenly forgot that I thought it was a change made in a certain Branch. I used git Co master and then checked it with GIT branch,

 

git branch* (no branch)  master
git branch
* master

 

I was shocked. Many of the previous changes were lost, and there was only one master branch. Fortunately, it prompted no branch and other words. I searched Google and found that someone had encountered such a situation.

Http://serverfault.com/questions/56722/git-seemed-to-be-in-no-branch-and-then-lost-my-changes

 

The GIT reflog command in Ubuntu does not automatically complete it. Therefore, this record is required in a timely manner.

The solution is shown in the preceding link:

Git reflog

You can check which version is the version you want to restore.

Then:

 

Git checkout ca2deraf (just an example)

It is better to use git checkout-B backup again

Back it up

The link is as follows:

Http://blog.csdn.net/jingwenlai_scut/article/details/5476967

Because there is a conflict with the remote server, it is actually done on (no branch) when resolving the conflict.

After a period of modification, I suddenly forgot that I thought it was a change made in a certain Branch. I used git Co master and then checked it with GIT branch,

 

git branch* (no branch)  master
git branch
* master

 

I was shocked. Many of the previous changes were lost, and there was only one master branch. Fortunately, it prompted no branch and other words. I searched Google and found that someone had encountered such a situation.

Http://serverfault.com/questions/56722/git-seemed-to-be-in-no-branch-and-then-lost-my-changes

 

The GIT reflog command in Ubuntu does not automatically complete it. Therefore, this record is required in a timely manner.

The solution is shown in the preceding link:

Git reflog

You can check which version is the version you want to restore.

Then:

 

Git checkout ca2deraf (just an example)

It is better to use git checkout-B backup again

Back it up

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.