我无意间把错误的档案 写错给Git 基特,但还没有将承诺推进到服务器上。
我如何解除那些承诺?当地当地仓库?
我无意间把错误的档案 写错给Git 基特,但还没有将承诺推进到服务器上。
我如何解除那些承诺?当地当地仓库?
当前回答
git reset --soft HEAD~1
或者如果你们记不起来,那末,你们可以使用
git rm --cached <file>
从存储库历史中移除文件的正确方式正在使用git filter-branch
。也就是说,
git filter-branch --index-filter 'git rm --cached <file>' HEAD
但我建议您谨慎使用此命令。 更多信息git-过滤器-分栏(1) 手册.
其他回答
要重置上一个修订版, 请永久删除所有未承诺的更改 :
git reset --hard HEAD~1
#1) $ git commit -m "Something terribly misguided"
#2) $ git reset HEAD~
[必要时编辑文件]
#3) $ git add .
#4) $ git commit -c ORIG_HEAD
简单的分步骤指南如下:
git reset --hard HEAD~1
git reset HEAD~1
git reset --soft HEAD~1
git reflog #to find the sh
reset --soft
或reset --hard
?@Kyralessa的回答:
如果您不确定该使用什么--soft
(我用这个公约来纪念它)s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
如果您选择了--hard
你会犯错,你会犯错输 输之前没有的更改。如果您选择--soft
犯错后,您也可以得出相同的结果。--hard
通过应用附加命令
git reset HEAD file.html
git checkout -- file.html
echo "some changes..." > file.html
git add file.html
git commit -m "wrong commit"
# I need to reset
git reset --hard HEAD~1 (cancel changes)
# OR
git reset --soft HEAD~1 # Back to staging
git reset HEAD file.html # back to working directory
git checkout -- file.html # cancel changes
感谢@Kyralessa。