参考git中的前一个/下一个提交? [英] Referring to the previous/next commit in git?
问题描述
我已经看到git命令使用了诸如 HEAD〜
之类的语法,但是我一直没能在Git 参考手册。
以下是我所了解的内容:< commit>〜< n>
指< commit> 之前的提交 commit〜
只是意味着相同,而< n> 隐含地是一。
现在,这是正确的吗?在这种情况下,这是否总是有效?如果< commit> 是两个分支之间合并的结果,那么提交将会引用< commit>〜
是否有一些对应的语法用于引用下一个提交或稍后的提交< n> 步骤?
- 〜用于获取第一个父母
- ^可以用于获取其他父母(例如,合并为^ 2)
但是,您不要没有简单的方法来引用下一个提交,即使有更多令人费解的方法来获得它。
I have seen git commands use a syntax such as HEAD~
, but I haven't been able to find this syntax in the Git Reference Manual.
Here is what I have understood: <commit>~<n>
refers to the commit <n> steps earlier than <commit> (where <n> is an integer number), and commit~
simply means the same and that <n> implicitly is one.
Now, is this correct? In that case, does this always work? What if <commit> is the result of a merge between two branches, which commit will then <commit>~
refer to? Is there some corresponding syntax for referring to the next commit or the commit <n> steps later?
You have a very clear explanation of how this works in the chapter on Acenstry References in Pro Git :
- ~ is used to get the first parent
- ^ can be used to get the other parents (^2 for example for a merge)
But you don't have a simple way to reference the next commit, even if there are more convoluted ways to get it.
这篇关于参考git中的前一个/下一个提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!