3

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?

left side right side

Some of the labels with the hash:

One commit One commit One commit

love
  • 1,000
  • 2
  • 16
  • 35
Victor
  • 23,172
  • 30
  • 86
  • 125

1 Answers1

2

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.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
  • Thank you. Does the command change if the blue line is not the master branch, but a branch called "develop" (that branches from master in the first dot on February 27)? Thanks – Victor Jun 30 '16 at 12:28
  • @VictorP Yes, just change `master` to `develop`. In case you might regret, run `git branch backup_develop develop` to create a backup branch first, which can help get everything back easily. – ElpieKay Jun 30 '16 at 12:34