需要回去prev在git中提交,如何? [英] Need to go back to prev commit in git,How?
问题描述
我通过删除某些文件并完成 commit
来修改我的源目录。我做了一个 push origin master
到远程主机github。
现在我知道我需要那些文件的正常运作。现在我需要一种方法返回我的prev commit
,然后
是否可以这样做?我对git很陌生,我很困惑。
预先感谢。
git revert
创建一个新的提交,撤销一个或多个先前的提交。这通常是撤消已提交的提交的最佳方式。例如,该命令将恢复提交 abc1234 中的所有内容, code>直至包括最新的提交(
HEAD
):
git revert abc1234..HEAD
您也可以使用 git reset
,但此命令会更改历史记录,并会为使用存储库的其他人造成问题。一般而言,如果您想放弃尚未推送的更改(并且您确定以后不想再回来),则只应使用此命令。
I have modified my source directory by deleting certain files and done a commit
. And I did a push origin master
to remote host, github.
Now I came to know that I need those files for proper functioning. Now I need a way to go back my prev commit
and then push
to my remote host.
Is it possible to do so? I'm very new to git, I'm confused with it.
Thanks in advance.
git revert
creates a new commit that undoes one or more previous commits. This is usually the best way to undo commits that have already been pushed.
For example, this command would revert everything from the commit abc1234
up to and including the latest commit (HEAD
):
git revert abc1234..HEAD
You could also use git reset
, but this command changes history and would cause problems for anyone else who is using the repository. In general you should only use this command if you want to discard changes that haven't been pushed (and that you're sure you won't want to come back to in future).
这篇关于需要回去prev在git中提交,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!