Git Revision Graph Incorrect

200 Views Asked by At

I've a couple of repo's that contain a master and dev branch. Master represents releases while dev represents the current buildable version. There are also a number of other branches for features which are deleted after merging to dev.

I've recently changed to using the pull request workflow, before that, I performed squashed merges. Some repos are new and have always used the pull request workflow, however, one of the older repos (and most important) used the squashed merge. The revision graph looks like this

enter image description here

At this point, all changes have been committed and pull requests used to merge the changes. Ignoring customs and collections I'd expect a revision graph like this:

enter image description here

My questions are:

  • Is there anything wrong with the first revision graph?

  • How could I get the graph to be more like the second?

1

There are 1 best solutions below

0
On

Git actually does have symbolic references, in which one reference contains the name of another reference, rather than its value.

Until relatively recently, these mostly didn't work,1 except for the specific case of HEAD. The main HEAD is normally a symbolic reference to some other branch name. The git checkout command, or the new git switch in Git 2.23 and newer, manages this symbolic reference for you.

Meanwhile, reach remote, such as origin can have a symbolic HEAD, e.g., origin/HEAD -> origin/master. Your Git sets these up based on the results it gets when it asks the Git at the URL—the origin Git in this case—what branch its HEAD named. If their HEAD was a symbolic reference to their master, your origin/HEAD should be a symbolic reference to your origin/master.

But apart from these cases, each reference just holds a raw hash ID. The best2 way to draw this is to draw the reference holding the hash ID, or pointing to the Git object selected by that hash ID. Only symbolic references should be drawn as pointing to another reference.


1Try creating symbolic branch sym containing just-created branch name br:

git branch br
git symbolic-ref refs/heads/sym refs/heads/br

List the branches with git branch to make sure it worked. Now ask Git to delete branch sym:

git branch -d sym

Old versions of Git would delete branch br! If your Git deleted sym, you have a Git in which these symbolic refs work better.

2Best is, of course, a matter of opinion, but since I'm writing this answer, I get to use my opinion. :-)