如果使用-m 2会revert第二个commit,也就是62db4af。 $ git revert HEAD~1 --no-edit --mainline 2Finished one revert. [master]: created 526b346:"Revert "Merging in rails-2.3 branch""$ git log-1commit d64d3983845dfa18a5d935c7ac5a4855c125e474 Author: Nick Quaranto<nick@quaran.to>Date:...
如果使用-m 2会revert第二个commit,也就是62db4af。 $ git revert HEAD~1 --no-edit --mainline 2Finished one revert. [master]: created 526b346:"Revert "Merging in rails-2.3 branch""$ git log-1commit d64d3983845dfa18a5d935c7ac5a4855c125e474 Author: Nick Quaranto<nick@quaran.to>Date:...
revert可以作用于历史中任意的单一的commit节点,然而reset只能做到从当前最新的commit开始回滚。比如说,如果你想要只撤销一次旧的指定的commit,使用git reset,你则必须移除该commit和该commit之后出现的所有commits,然后再把那些随后的commit重新提交。毫无疑问,这种撤销的方式一点都不优雅。 示例1 下面的例子是git revert的...
#This is the commit message#2: Add file2 #This is the commit message#3: Add file3 #Please enter the commit messageforyour changes. Lines starting #with'#'will be ignored, and an empty message aborts the commit. # #Date: Sun Oct 11 09:37:05 2020 -0400 # #interactive rebaseinprogre...
git revert -n master~5..master~2 Revert the changes done by commits from the fifth last commit in master (included) to the third last commit in master (included), but do not create any commit with the reverted changes. The revert only modifies the working tree and the index. ...
Git revert 用于撤回某次提交的内容,同时再产生一个新的提交(commit)。原理就是在一个新的提交中,对之前提交的内容相反的操作。 下面通过例子具体解释一下: 现有一个git项目,已经有3次提交,每次添加一个文件,具体提交步骤如下: # 第一次提交 $ echo "first commit" > test.txt ...
(use "git restore <file>..." to discard changes in working directory) modified: Dockerfile no changes added to commit (use "git add" and/or "git commit -a") 这个例子显示 Dockerfile 已被更改。 2a. 把工作树(当前目录)恢复到索引(暂存区)的状态: ...
不过,在某些情况下,您可能不需要删除或重置上次提交。也许它只是过早制作的。在这种情况下,您可以修改最近的提交。在工作目录中进行了更多变更并使用git add将其暂存以供提交后,就可以执行git commit--amend了。这将让 Git 打开配置的系统编辑器,方便您修改最后的提交消息。新的变更将添加到修改后的提交中。
git revert The "revert" command helps you undo an existing commit. It's important to understand that it doesnotdelete any data in this process: instead, Git will createnewchanges with the opposite effect - and thereby undo the specified old commit....
git commit (take files from the staging index and save them in the repository) git commit -m git commit --amend (alter the most recent commit) git revert (reverse the given commit) Relative Commit References git reset (erase commits) git diff (displays the difference between two versions of...