What is the opposite of `git diff HEAD^`?

前端 未结 3 1344
死守一世寂寞
死守一世寂寞 2021-02-03 22:57

In git, I can specify the previous revision by saying HEAD^ or HEAD~1. What about going the other way? Suppose I\'m on revision X, and I do git c

3条回答
  •  长发绾君心
    2021-02-03 23:37

    As far as I can tell there's no symbolic way to refer to the children of a commit.

    The best I can give you just now is the --children option of git rev-list. Here I ask for the four most recent commits to be pretty-printed, plus information on their children. Note that on the "commit" line of each entry (other than the most recent) there is an extra commit number, which specifies the child of that node. You could grab that either manually or through some shell scripting to get to the child.

    $ git rev-list --children --pretty HEAD~3...
    
    commit 20dba296ad1d48ec90f9319e2c13b245e849f698
    Author: Somebody <____@____.net>
    Date:   Thu May 6 19:10:38 2010 -0400
    
        Support for complex trig/pow.
    
    commit 9d42b5bac1721a847a39c25672e577c7101c8ff0 20dba296ad1d48ec90f9319e2c13b245e849f698
    Author: Somebody <____@____.net>
    Date:   Wed May 5 21:55:07 2010 -0400
    
        Fix doc formatting warning.
    
    commit 72bed3baa9df71cb224dfa8388b5969d50f5567c 9d42b5bac1721a847a39c25672e577c7101c8ff0
    Merge: b8244cb61491c9cdb83d36e57f8eb49773e44f6b 899c3dd3f9f419f200b84ca0abe59d7ac3d5bb53
    Author: Somebody <____@____.net>
    Date:   Wed May 5 21:54:59 2010 -0400
    
        Merge branch 'master' 
    
    commit 899c3dd3f9f419f200b84ca0abe59d7ac3d5bb53 72bed3baa9df71cb224dfa8388b5969d50f5567c
    Author: Somebody <____@____.net>
    Date:   Wed May 5 21:19:11 2010 -0400
    
        Fix link
    

提交回复
热议问题