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

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


当前回答

我发现这笔该网站描述如何撤销您在存储库中的承诺 。

一些命令 :

git commit --amend        # Change last commit
git reset HEAD~1 --soft   # Undo last commit

其他回答

enter image description here

假设您在视觉工作室工作, 如果您进入分支历史, 并查看您的所有承诺, 只需在承诺之前选择事件, 您想要撤销, 右单击它, 然后选择Revert轻而易举

与您一起工作的人源树树这会帮助你。

右单击右键在那日,选定 "重置( 当前分支)/ master 用于此承诺" 和上一个选定 “ 软” 重置.

Enter image description here

如果你有Git 外加已安装, 您可以运行git undo撤消最近的承诺。git undo 3将撤销最后三项承诺。

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

是私人分行还是私人分行

    git commit -m 'Replace .class files with .java files'

如果它是共享的或公共的分支。