2012-03-30 31 views
1

真的,我是即将使用git的新手,但我希望我没有放松太多的工作。我已经尝试切换到主分支,但正如你可以看到没有成功。转换分支的惊喜

[email protected] /d/workspace/android/tutorialA2 (about_screen) 
$ git st 
# On branch about_screen 
nothing to commit (working directory clean) 

[email protected] /d/workspace/android/tutorialA2 (about_screen) 
$ git br 
master 
* about_screen 

[email protected] /d/workspace/android/tutorialA2 (about_screen) 
$ git co master 
Unlink of file 'res/layout/view_about.xml' failed. Should I try again? (y/n) y 
Unlink of file 'res/layout/view_about.xml' failed. Should I try again? (y/n) err 
or: unable to unlink old 'res/layout/view_about.xml' (Permission denied) 

现在,当我想提出一个结账到最后稳定的承诺,我得到这个消息:

$ git co 8759ba 
fatal: Unable to create 'd:/workspace/android/tutorialA2/.git/index.lock': File exists. 

If no other git process is currently running, this probably means a 
git process crashed in this repository earlier. Make sure no other git 
process is running and remove the file manually to continue. 
+0

'ls -l res/layout/view_about.xml' – Reactormonk 2012-03-30 17:33:49

+0

@Tass:我有那个文件。问题是我失去了一些文件和版本。 Git说我修改并删除了一些文件,但我没有。我怎样才能恢复到以前的稳定版本,即最后一个git状态 – 2012-03-30 18:50:52

+0

另一个进程是否打开了该文件?如果您不确定,请尝试重新启动后检查它。 – Andy 2012-03-30 18:59:13

回答

0

你似乎有两个问题。

  1. 您对res/layout/view_about.xml有权限问题。您应该检查并更正该文件的权限。

  2. Git有一个锁定文件。如果没有其他git进程正在运行,请按照错误消息中的说明删除锁定文件。

一旦你做了这两件事,你应该回到可以自由切换分支的状态。

一旦你能做到这一点,您可以重置之前的一个分支提交,以“混帐的复位 - 硬<SHA1>”里<SHA1>是你想返回的提交ID。请注意,此命令具有破坏性 - 它会执行您所说的内容,并使您的工作目录看起来像它在提交时的状态。在你做之前确定它是你想要的。如果你弄错了,有办法恢复,但最好不要错。