Version Control - How to check which branch the current git branch is based on?
滿天的星座2017-05-17 10:02:04
0
4
1514
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?
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.
git reflog --date=local | grep <branchname>
You can check this out: http://stackoverflow.com/ques...
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
or
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.
git remote show origin
View the remote address, remote branch, and the corresponding relationship between the local branch and the remote branch.
git checkout -
Cut to the previous branch and run twice, once to the previous branch and once to switch back