我无意间把错误的档案 写错给Git 基特,但还没有将承诺推进到服务器上。
我如何解除那些承诺?当地当地仓库?
我无意间把错误的档案 写错给Git 基特,但还没有将承诺推进到服务器上。
我如何解除那些承诺?当地当地仓库?
当前回答
删除已被推到 Github 的错误行为
git push origin +(previous good commit id):(branch name)
请指定您想要在 Github 重置的最后一个好承诺代号 。
例如,如果最近的承诺 ID 错误, 请用分支名称在 Git 命令上方指定前一个承诺 ID 。
您可以使用git log
其他回答
为了撤销最后的本地承诺, 在不丢弃其改变的情况下, 我有一个便用的别名~/.gitconfig
[alias]
undo = reset --soft HEAD^
然后,我简单地使用git undo
这是超容易记住的。
您可以使用git revert <commit-id>
.
为了得到身份证明 只需使用git log
.
#1) $ git commit -m "Something terribly misguided"
#2) $ git reset HEAD~
[必要时编辑文件]
#3) $ git add .
#4) $ git commit -c ORIG_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 :)