$ git reset HEAD hello.phpUnstagedchanges after reset:M hello.php $ git status-s M README M hello.php 现在你执行 git commit,只会将 README 文件的改动提交,而 hello.php 是没有的。 $ git commit-m'修改'[master f50cfda]修改1file ch
当你执行一个git commit,GIT就创建一个新的commit,随后HEAD就指向这个新的commit,而index,working copy的状态和HEAD就又完全匹配相同了,GIT又一次HAPPY了。 下面这一段是另外一个牛人的解释: 总的来说,git reset命令是用来将当前branch重置到另外一个commit的,而这个动作可能会将index以及work tree同样影响。比如如...
方案二:git对已经修改的文件会有缓存,但前提是之前提交(commit)过代码。我还没有commit过。所以 git...
完全不触及索引文件或工作树(但将头重置为<提交>,就像所有模式都做的那样)。这使所有已更改的文件保持 "Changes to be committed" 状态,就像git status会显示的那样。 --mixed 重置索引,但不重置工作树(即保留已修改的文件,但不标记为提交)并报告哪些内容未更新。这是默认动作。
http://web.mit.edu/~mkgray/project/silk/root/afs/sipb/project/git/git-doc/git-reset.html 一、基本篇 在git的一般使用中,如果发现错误的将不想staging的文件add进入index之后,想回退取消,则可以使用命令:git reset HEAD <file>...,同时git add完毕之后,git也会做相应的提示,比如: 引用 # Changes to...
git reset --soft <commit> - Move HEAD to commit, keep changes staged git reset --mixed <commit> - Move HEAD to commit, unstage changes (default) git reset --hard <commit> - Move HEAD to commit, discard all changes git reset <file> - Unstage a file git log --oneline - Show ...
Git reset soft is a very safe way to move back to a prior point in your Git history and preserve all changes. Since the changes are preserved, this is one way to rewrite your history, applying all the changes across multiple commits into one commit while providing a path for making addit...
$ git add file1.txt You can also directly use thegit add .command to move all your changes to the Staging Area. Let’s check the status of our project now: $ git status Git highlightsfile1.txtin green, indicating that it’s inside our Staging Area. ...
On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: read.me Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modifie...
1. 首先,查看 Git 的跟踪状态只会看到文件有更改: $ git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working direct...