git reset --soft HEAD"^" (2)把最后的commit切回Changes not staged for commit状态,使用命令: git reset HEAD^ (3)把Changes to be committed状态切回Changes not staged for commit状态,使用命令: git reset HEAD <file>... # 单个文件 git reset HEAD -- . # 所有Changes to be co...
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (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 已被更改。
--soft: Does not touch the index file or the working tree at all (but resets the head to ``, just like all modes do). This leaves all your changed files "Changes to be committed", as `git status` would put it.仅仅重置HEAD指向``,而并不会改变暂存区和工作区的内容。--...
At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong. One...
However, in some cases, youcommittedsome files that should not be pushed to your Git repository. Sometimes, you may want to perform additional changes before issuing the commit. As a consequence, you need toundo the last commitfrom your Git repository. ...
Undoing Uncommitted Changes The first approach we're going to look at in undoing changes is how to undo changes you've made but not yet committed. Whether you've staged these changes or not, what matters is that you haven't committed them. Let's make some changes to the third file we...
Example:add text to some file, stage (add) changes, and then unstage those changes: Change and add the file: $ echo "bar" >> my-file.txt $ git add my-file.txt $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) ...
...# Changes to be committed: # (use "git rm --cached <file>..." to unstage)... And the solution indeed is to usegit rm --cached FILE Note the warnings elsewhere here -git rmdeletes your local working copy of the file, butnotif you use--cached. Here's the result of git hel...
# Changes to be committed: # (use "git rm --cached <file>..." to unstage) ... 1. 2. 3. 4. And the solution indeed is to usegit rm--cachedFILE Note the warnings elsewhere here -git rmdeletes your local working copy of the file, butnotif you use--cached. Here's the result...
Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: README.md Copy The--softflag ensures that the only thing modified when running thegit resetcommand is the log that git keeps. If you also want to restore the contents of git repository to an older ...