问题
In the Github's network view of my git repository, there is a "phantom" branch that has no name. Please see the picture below.
For the sake of simplicity I would like to remove the black branch (leaving only the blue branch).
How can this be done?
Some of the labels with the hash:
回答1:
Assume the black branch starts at Commit A, and ends at Commit Z. Both A and Z are the blue dots. In the cmd, A and Z are the commit sha1.
git rebase --onto Z^2 A master
This makes a linear history. But if doing so, you must git push origin -f master:master
to update the remote master by force and inform every member to fetch and track the new master and abandon the old one.
来源:https://stackoverflow.com/questions/38113359/how-to-remove-unnamed-branch-in-git-shown-in-github-network-view