git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend] [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)] [-F <file> | -m <msg>] [--reset-author] [--allow-empty] [
(use "git restore <file>..." to discard changes in working directory) modified: src/main/java/com/example/learnspringboot/LearnspringbootApplication.java no changes added to commit (use "git add" and/or "git commit -a") 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 接下来提交到索引区,接...
git reset HEAD <file_name> = git restore --staged <filename> 丢弃暂存区的修改,重新放回工作区,会将暂存区的内容和本地已提交的内容全部恢复到未暂存的状态,不影响原来本地文件(相当于撤销git add 操作,不影响上一次commit后对本地文件的修改) (包括对文件的操作,如添加文件、删除文件) --hard git ...
记住: git checkout -- [文件名](或 git restore [文件名])命令可以丢弃工作区里未暂存的修改。它会用暂存区或版本库中的版本覆盖工作区的文件。 情况二:修改已添加到暂存区(已经 git add,但没有 git commit) 场景: 你在工作区做了修改,然后执行了 git add [文件名] 命令,将改动添加到了暂存区。此时 ...
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)$ git statusOn branch masterChanges not stagedforcommit:(use"git add <file>..."to update what will be committed)(use"git restore <file>..."to discard changesinworking directory)modified: readme.txtno changes added to commit ...
1、git checkout [file] 【恢复暂存区的指定文件到工作区】 2、git checkout [commit] [file] 【恢复某个commit的指定文件到暂存区和工作区】 3、git checkout .【本地所有修改的。没有的提交的,都返回到原来的状态】 4、git reset [file]【重置暂存区的指定文件,与上一次commit保持一致,但工作区不变】...
Let’s look at a few ways to restore the lost code, depending on how convinced you were at the time that you really wanted the file to be deleted! I deleted a file but didn’t commit So you deleted a file, and immediately realized it was a mistake? This one is easy, just do: ...
$ git restore --staged CONTRIBUTING.md $ git status On branch master Changes to be committed: (use "git restore --staged <file>..." to unstage) renamed: README.md -> README Changes not staged for commit: (use "git add <file>..." to update what will be committed) ...
After running git reset <pathspec> to update the index entry, you can use git-restore[1] to check the contents out of the index to the working tree. Alternatively, using git-restore[1] and specifying a commit with --source, you can copy the contents of a path out of a commit to th...
Once you've found the commit you want to undo, usegitrevertto create a new commit that reverses the changes: Example gitrevert HEAD --no-edit [master e56ba1f] Revert "Just a regular update, definitely no accidents here..." Date: Thu Apr 22 10:50:13 2021 +0200 1 file changed, 0...