I have a serious issue happened to my git repository. I had 2 branches previously, and I wrote codes last night and forgot to push to the github. This morning I used the other machine and tried fork a new branch and push them up(the codes are stored in dropbox so it doesn’t matter which machine I’m using), then git gave me error say: “permission denied”. Then I realized that I’m not using my labtop, so I opened up my labtop and tried to get into the branch I just created. But then it seems like I cannot do that, and what was worse, all the codes that I committed on the other machine are gone! I use git branch to see the branch listing and now it’s like:
centeredForm (shang's conflicted copy 2011-08-08)
* centeredform
master
refinement
where the first “centeredForm” is the branch I created on the other machine, and “centeredform” is the branch I created on my labtop afterwards. Are my codes gone? Or is there a way to restore to previous status?
If it was commited, then it’s not lost. There’s always the history:
Then you can grab the SHA of your last commit, and undo any mess:
IMPORTANT: Backup everyhing first. The
reset --hardwill delete all non-commited changes.