Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Merge with squash but keep network graph

Let's say I have development branch and FixBullshit branch and I have 5 commits in FixBullshit, I do a pull request but merge development with FixBullshit with merge + squash to keep it in development as 1 commit to keep it clearer (is it the best option, by the way?)

The thing is, after doing that, in the network graph of github it looks like Bullshit branch went out of development, but it never merged and then there appears 1 commit in development but there's not relation to Bullshit branch, like it happens in my git https://github.com/noxerr/VRHarry/network with branches development and "fixSensorsinput"

what am I doing wrong? how could I create that link on the network?

like image 446
Daniel Roca Lopez Avatar asked Oct 21 '17 22:10

Daniel Roca Lopez


2 Answers

The network graph shows the history of the git repo, and "squashing" alters history by compressing it.

What Github is doing is taking this graph

A--B--C--D--E
    \
     F--G--H

squashing F--G--H into a single commit W, and applying it as

A--B--C--D--E--W
    \
     F--G--H

To do what you are suggesting, you could squash F--G--H together into a commit Q before merging to make a graph like

A--B--C--D--E--I
    \         /
     Q--------

Unfortunately, this form of squash merging alters history, which can cause problems for those with a local copy of the old history. This is probably why Github squash merges as described above, instead of like this.

There are many pages on the internet like this one about the advantages and disadvantages of squashing, rebasing, and other merge methods.

like image 64
rlee827 Avatar answered Nov 14 '22 23:11

rlee827


If you do it then you will lose the track of the branches because this is the way git works

like image 35
Dani Roca Avatar answered Nov 14 '22 23:11

Dani Roca