search

Home  >  Q&A  >  body text

Version Control - How to check which branch the current git branch is based on?

For example, I cut out a branch B from branch A
and then performed a series of operations on branch B
and then forgot Which branch branch B was cut from?
Can you find out which branch it was created on?

滿天的星座滿天的星座2775 days ago1498

reply all(4)I'll reply

  • 迷茫

    迷茫2017-05-17 10:04:04

    git reflog --date=local | grep <branchname>
    You can check this out: http://stackoverflow.com/ques...

    reply
    0
  • 高洛峰

    高洛峰2017-05-17 10:04:04

    You can find the branch it is based on by viewing the commit log, that is, using the git log命令,不过需要借助一些命令选项。你可以使用--decorate选项来在提交日志中显示分支信息,以及--graph选项以ASCII图形形式显示分支历史,当然你还需要--all option to ensure that all branch information is displayed:

    That’s

    git log --graph --all --decorate

    or

    git log --graph --all --decorate=short

    Then you can find the current branch in the results and follow the line of the branch to find its parent branch. Because the colors between adjacent branches are different, you should be able to find it if you look carefully.

    The method is a bit clumsy, please forgive me. I hope someone can give me a better way.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-17 10:04:04

    git remote show origin
    View the remote address, remote branch, and the corresponding relationship between the local branch and the remote branch.

    reply
    0
  • 为情所困

    为情所困2017-05-17 10:04:04

    git checkout -
    Cut to the previous branch and run twice, once to the previous branch and once to switch back

    reply
    0
  • Cancelreply