在git中〜和^有什么区别 [英] What's the difference between ~ and ^ in git

查看:101
本文介绍了在git中〜和^有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我早就问过这个问题了,但我仍然不知道在这个答案中〜和^是什么意思:


如果你正在谈论远程分支,比如origin / master,你可以使用$和b来引用〜和^祖先提交相对于一个分支相同的
的方式,你可以与当地分行


有什么区别?

解决方案

^ 表示(first)parent of。 是类似的,但它将一个数字作为参数,基本上意味着祖先的。因此,例如:

pre $ HEAD =最新提交
HEAD ^ = HEAD〜1 =最新提交的父项
HEAD ^^ = HEAD〜2 =最新提交的祖父母
HEAD〜100 =最近提交的第100个祖先


I asked this question long ago but I still don't know what do ~ and ^ mean in this answer:

If you're talking about a remote branch, say, origin/master, you can use ~ and ^ to refer to ancestor commits relative to a branch the same way you can with local branches

What's the difference?

解决方案

^ means "(first) parent of". ~ is similar, but it takes a number as an argument and basically means "ancestor of". So, for example:

HEAD            = latest commit
HEAD^  = HEAD~1 = parent of latest commit
HEAD^^ = HEAD~2 = grandparent of latest commit
HEAD~100        = 100th ancestor of latest commit

这篇关于在git中〜和^有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆