mirror of
https://github.com/LucasVbr/first-contributions.git
synced 2026-05-13 17:21:50 +00:00
42242c1aa9
(1)installing-git-arch.zh-cn.md (2)installing-git-ubuntu.zh-cn.md (3)keeping-your-fork-synced-with-this-repository.zh-cn.md (4)resetting-a-commit.zh-cn.md (5)squashing-commits.zh-cn.md (6)stashing-a-file.zh-cn.md (7)storing-credentials.zh-cn.md
787 B
787 B
重置一个提交
reset 是一个用于将仓库回退到之前某个提交的命令,丢弃该提交之后的所有更改。
重置和撤销提交的主要区别在于,git reset 取消暂存文件并将我们的更改带回工作目录
而 git revert 从远程仓库中删除提交。
git reset 可以通过以下命令来实现:
-
以下命令将以两个参数的方式给出所有提交的摘要:
- 提交哈希的前七个字符 - 这是我们在 reset 命令中需要引用的内容。
- 提交信息
git log --oneline
- 可以使用以下命令将仓库重置到特定的提交:
git reset commithash其中 commithash 是我们在日志中找到的提交哈希的前 7 个字符。