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

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


当前回答

以下是网站: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 :)

其他回答

撤销最后一次承诺的最简单方式是

git reset HEAD^

这将带来项目状态 之前,您已经做出承诺。

以下是网站: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 :)

为了完整起见,我将提出前几个答复所忽略的一个明显明显的方法。

由于承诺没有被推,遥控器没有改变,因此:

  1. 删除本地仓库 。
  2. 克隆远程仓库 。

有时候,如果你的高贵的Git客户告别(看着你,伊吉特),这有时是必要的。

别忘了重新承诺保存已保存上次按键后的变化 。

视觉演播室代码使得这很容易。

VS Code

如果您只是想要丢弃所有本地更改/ 承诺, 使您的本地分支看起来像您从... 开始的源分支...

git reset --hard origin/branch-name