Git 切换分支的惊喜
确实,当我即将使用git时,我是新手,但我希望我没有失去太多的工作。我试着切换到主分支,但正如你所看到的,没有成功Git 切换分支的惊喜,git,branch,Git,Branch,确实,当我即将使用git时,我是新手,但我希望我没有失去太多的工作。我试着切换到主分支,但正如你所看到的,没有成功 Alx@I5-PC /d/workspace/android/tutorialA2 (about_screen) $ git st # On branch about_screen nothing to commit (working directory clean) Alx@I5-PC /d/workspace/android/tutorialA2 (about_screen)
Alx@I5-PC /d/workspace/android/tutorialA2 (about_screen)
$ git st
# On branch about_screen
nothing to commit (working directory clean)
Alx@I5-PC /d/workspace/android/tutorialA2 (about_screen)
$ git br
master
* about_screen
Alx@I5-PC /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.
你似乎有两个问题
一旦可以这样做,就可以使用“git reset--hard”将分支重置为上一次提交,其中是要返回的提交的ID。请注意,此命令是破坏性的-它将执行您告诉它的操作,并使您的工作目录看起来像提交时的状态。在你做之前,确保它是你想要的。如果你弄错了,有很多方法可以恢复,但最好不要弄错。
ls-l res/layout/view\u about.xml
@Tass:我有那个文件。问题是我丢失了一些文件和版本。Git说我修改和删除了一些文件,但我没有。如何恢复到上一个git状态的previus稳定版本?另一个进程是否打开了该文件?如果您不确定,请尝试在重新启动后检查它。我认为您添加的错误消息相当直接。如果没有打开另一个git进程,请手动删除锁file@doledoug这不是问题,我想要那个命令的完整输出。