The first command restores hello.rb to the version in the index, so that "git diff hello.rb" returns no differences. The second command will restore hello.rb to the version in the HEAD revision, so that both "git diff hello.rb" and "git diff --cached hello.rb" return no differences....
# r, reword <commit> = use commit, but edit the commit message # e, edit <commit> = use commit, but stop for amending # s, squash <commit> = use commit, but meld into previous commit # f, fixup <commit> = like "squash", but discard this commit's log message # x, exec ...
将git-status[1]的输出包含在提交消息模板中。默认情况下启用,但可以用于覆盖配置变量commit.status。
gitrestore--worktreedemo.txt//撤销文件工作区的修改gitrestore--stageddemo.txt//撤销暂存区的修改,将文件状态恢复到未add之前gitrestore-sHEAD~1demo.txt//将当前工作区切换到上个 commit 版本,-s相当于--sourcegitrestore-shadn12demo.txt//将当前工作区切换到指定commitid的版本 暂存区 通过git add filename...
git-revert[1]is about making a new commit that reverts the changes made by other commits. git-restore[1]is about restoring files in the working tree from either the index or another commit. This command does not update your branch. The command can also be used to restore files in the ...
$ git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) We can now commit the changes to complete the merge: $ git commit -am 'Squashed and merged the gh-actions-demo branch' [main fa...
通常也会添加一个last命令,像这样: $ git config --global alias.last 'log -1 HEAD' 这样,可以轻松地看到最后一次提交: $ git last commit 66938dae3329c7aebe598c2246a8e6af90d04646 Author: Josh Goebel <dreamer3@example.com> Date: Tue Aug 26 19:48:51 2008 +0800 ...
We need to do 2 things which is to first unstage it from being commit. Then we can restore the file back to its latest committed state. The second command is destructive. git restore --staged <file> git restore <file> If you want to get fancy you can do: git restore --stage <...
If<pathspec>names an active submodule and the restore location includes the working tree, the submodule will only be updated if this option is given, in which case its working tree will be restored to the commit recorded in the superproject, and any local modifications overwritten. If nothing ...
# Restore the file in the staging index #译者注:复制HEAD所指commit的test01文件到index中 git reset HEAD test01 # Get the old version from the staging index #译者注:复制index中test01到工作副本中 git checkout test01 #译者注,以上两条命令可以合并为git checkout HEAD test01 ...