Difference between git reset --hard HEAD^ vs git reset --hard HEAD?

ahtmatrix

What does the ^ in git reset --hard HEAD^ do versus just git reset --hard HEAD Is there a difference?

Paul

HEAD^ is the parent commit of HEAD.

If you want to go into details, then ref^ is the shortcut for ref^1 where ref^1 is the commit's first parent (ref^2 is the commit's second parent, which may be absent if the commit is not a merge commit).

There is also ref~ which is also commit's first parent. It is also a shortcut for ref~1. But the difference between ref^2 and ref~2 is that ref~2 is commit's first parent's first parent. There can be ref~1, ref~2, ..., ref~n (if the history is long enough).

As for the git reset - it resets the current branch to the commit you specify (--hard means to discard both index and working tree changes). git reset --hard HEAD^ resets the current branch one commit backward, while git reset --hard HEAD just discards all local changes.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

git reset --hard HEAD留下未跟踪的文件

如何使用'git reset --hard HEAD'恢复到先前的提交?

从git reset --hard恢复?

如何撤消git reset --hard HEAD〜1?

git reset vs git reset HEAD

git reset --hard HEAD ^与git reset --hard HEAD之间的区别?

“ git checkout-”和有什么不一样?和“ git reset HEAD --hard”?

“ git reset --hard”是否与“ git reset --hard HEAD”相同?

git reset HEAD ^ --hard删除所有内容吗?

为什么`git reset --hard HEAD〜X`会留下未跟踪的文件?

git undo命令:“ git reset --hard”

git reset --hard <commit id>之后下一次提交时的HEAD

有没有办法执行高性能git reset --hard HEAD?

git checkout和有什么不一样?vs git reset --hard HEAD

git rebase中止后,git reset --hard错误:警告:ref HEAD的日志在DD / MM / YYY TTTT上意外结束

git reset --hard HEAD〜1和git reset HEAD〜1 --hard之间的区别?

git checkout HEAD-之间有区别吗?和git reset --hard HEAD吗?

在git reset --hard HEAD @ {1}之后,是否可以恢复未执行的更改?

在“ git commit --amend”之后的“ git reset --hard HEAD”

git revert reset --hard命令

如何撤消`git reset --hard HEAD〜1`?

git reset --hard HEAD ^后未运行的文件丢失,而无需运行git add-我可以找回它们吗?

Git reset --hard head(revert)不更新Windows中的Symbolic Link目标

从git reset --hard恢复

Git 如何让 git reset --hard 工作?

尽管“git reset --hard HEAD~1”,不需要/未跟踪的文件仍在 .git 目录中

“git reset --hard”的行为

git reset --hard HEAD 后恢复初始文件~

使用 git reset --hard "commit id",現在我的 HEAD 分離了