我无意间把错误的档案 写错给Git 基特,但还没有将承诺推进到服务器上。

我如何解除那些承诺?当地当地仓库?


当前回答

如果您想要还原最后一个任务, 但仍要保留在任务中本地作出的更改, 请使用此命令 :

git reset HEAD~1 --mixed

其他回答

以下是网站:Oh shit, git!.

这里有许多解密的秘方 如何在Git 中解决事情。其中一些是:

哦,该死,我需要改变 信息在我的最后一次承诺!

git commit --amend
# follow prompts to change the commit message

哦,我无意中把什么东西 给了主人 本来该在全新的树枝上!

# Create a new branch from the current state of master
git branch some-new-branch-name
# Remove the commit from the master branch
git reset HEAD~ --hard
git checkout some-new-branch-name
# Your commit lives in this branch now :)

我拿到了身份证明bitbucket并随后:

git checkout commitID .

示例:

git checkout 7991072 .

它又把它恢复到那个承诺的工作副本上。

仅使用git reset --hard <last good SHA>重新设置修改并给予新的承诺。您也可以使用git checkout -- <bad filename>.

使用使用git revert <commit-id>.

要拿到身份证明,请使用git log.

要重置上一个修订版, 请永久删除所有未承诺的更改 :

git reset --hard HEAD~1