Git:尝试重置 origin/master 以提交时发生致命错误
Git: fatal error occurs while trying to reset origin/master to commit
我遇到以下情况:
master is 2 behind on origin master
我是如何陷入这种情况的:
首先在 Sourcetree 中应用 'Reset master to this commit'。但后来我意识到我应该撤销推送的提交 How to rollback everything to previous commit。这就是我后来所做的。
由于我是 Git 的新手,为了进行测试,我取消了 2 个不需要的提交,再次意识到我不想要它们,然后再次重做上面的操作,除了拉动。
我试图再次撤销两个不需要的提交,但我只能撤销一个并收到以下消息:
fatal: Unable to create '/Users//.git/index.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
我试图将 origin/master 重置为我的本地主指针。继Git, How to reset origin/master to a commit?之后,这需要做
git checkout master
git reset --hard e3f1e37
git push --force origin master
当我执行 git checkout master
时,我再次收到相同的消息。
即使我想为下一次提交提取或暂存文件,我也会收到相同的消息。
所以我认为没有其他 git 进程 运行。 git 进程绝对有可能因我的所有尝试和存储库中的 (Unity) 应用程序 运行 而崩溃。但是要手动删除哪个文件?怎么找?
我只使用这个存储库。所以我不介意一个极端的解决方案,只要我有一个干净的副本可以再次使用。因为现在我执行的每个 git 操作都会收到上述消息。
编辑:解决方案与可能重复项 link 中提到的相同。没有产生错误的情况。例如,我,只有 ET 知道为什么,没有查找错误消息。也许会有其他人遇到这种特殊情况。
那么它是否重复?请告诉我。
But which file to remove manually?
错误信息告诉您:/Users//.git/index.lock
.
How to find it?
可能您已经从错误消息中删除了您的用户名,但是如果您导航至 C:\Users\[username]\.git
(Windows) 或 /Users/[username]/.git
(macOS),您将看到 index.lock
你可以删除。
So I wouldn't mind a drastic solution as long as I have a clean copy to work on again.
我遇到以下情况: master is 2 behind on origin master
我是如何陷入这种情况的: 首先在 Sourcetree 中应用 'Reset master to this commit'。但后来我意识到我应该撤销推送的提交 How to rollback everything to previous commit。这就是我后来所做的。 由于我是 Git 的新手,为了进行测试,我取消了 2 个不需要的提交,再次意识到我不想要它们,然后再次重做上面的操作,除了拉动。 我试图再次撤销两个不需要的提交,但我只能撤销一个并收到以下消息:
fatal: Unable to create '/Users//.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.
我试图将 origin/master 重置为我的本地主指针。继Git, How to reset origin/master to a commit?之后,这需要做
git checkout master
git reset --hard e3f1e37
git push --force origin master
当我执行 git checkout master
时,我再次收到相同的消息。
即使我想为下一次提交提取或暂存文件,我也会收到相同的消息。
所以我认为没有其他 git 进程 运行。 git 进程绝对有可能因我的所有尝试和存储库中的 (Unity) 应用程序 运行 而崩溃。但是要手动删除哪个文件?怎么找?
我只使用这个存储库。所以我不介意一个极端的解决方案,只要我有一个干净的副本可以再次使用。因为现在我执行的每个 git 操作都会收到上述消息。
编辑:解决方案与可能重复项 link 中提到的相同。没有产生错误的情况。例如,我,只有 ET 知道为什么,没有查找错误消息。也许会有其他人遇到这种特殊情况。 那么它是否重复?请告诉我。
But which file to remove manually?
错误信息告诉您:/Users//.git/index.lock
.
How to find it?
可能您已经从错误消息中删除了您的用户名,但是如果您导航至 C:\Users\[username]\.git
(Windows) 或 /Users/[username]/.git
(macOS),您将看到 index.lock
你可以删除。
So I wouldn't mind a drastic solution as long as I have a clean copy to work on again.