Referencing the child of a commit in Git

后端 未结 10 1116
失恋的感觉
失恋的感觉 2020-11-28 08:37

If you want to move the HEAD to the parent of the current HEAD, that\'s easy:

git reset --hard HEAD^

But is there

10条回答
  •  醉梦人生
    2020-11-28 09:23

    You can use the gist of the creator for Hudson (now Jenkins) Kohsuke Kawaguchi (November 2013):
    kohsuke / git-children-of:

    Given a commit, find immediate children of that commit.

    #!/bin/bash -e
    # given a commit, find immediate children of that commit.
    for arg in "$@"; do
      for commit in $(git rev-parse $arg^0); do
        for child in $(git log --format='%H %P' --all | grep -F " $commit" | cut -f1 -d' '); do
          git describe $child
        done
      done
    done
    

    Put that script in a folder referenced by your $PATH, and simply type:

    git children-of 
    

提交回复
热议问题