How to find the nearest parent of a Git branch?

后端 未结 21 1710
野性不改
野性不改 2020-11-22 00:54

Let\'s say I have the following local repository with a commit tree like this:

master --> a
            \\
             \\
      develop c --> d
               


        
21条回答
  •  梦如初夏
    2020-11-22 01:22

    git log -2 --pretty=format:'%d' --abbrev-commit | tail -n 1 | sed 's/\s(//g; s/,/\n/g';
    

    (origin/parent-name, parent-name)

    git log -2 --pretty=format:'%d' --abbrev-commit | tail -n 1 | sed 's/\s(//g; s/,/\n/g';
    

    origin/parent-name

    git log -2 --pretty=format:'%d' --abbrev-commit | tail -n 1 | sed 's/(.*,//g; s/)//';
    

    parent-name

提交回复
热议问题