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?
迷茫2017-05-17 10:04:04
git reflog --date=local | grep <branchname>
You can check this out: http://stackoverflow.com/ques...
高洛峰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.
我想大声告诉你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.
为情所困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