GitHub Merge 'master' branch

Tried Git and Github after many years of using svn. I seem to have the basics, but one thing bothers me.

  • UserA makes changes to FileA and clicks on the remote server (GitHub)

  • UserB makes changes to FileB. First, it pulls the server from the remote server, and then drags its change to FileB on the remote server

  • GitHub commit history shows click on UserA and click UserB

  • However, there is an additional entry in the commit history from UserB, called β€œMerge branch” https://github.com/xxx/yyy '. Viewing diff on Github shows that this is an exact copy of the changes made by UserA to FileA

Why this duplicate is shown - both clicks from UserA to FileA and Merge merge wizard entries are identical ... the second seems to me superfluous.

+42
git github
Aug 19 '11 at 10:21
source share
1 answer

Each version ("commit") stored in git forms part of the graph, and it is often useful to think about what you do in git in terms of this graph.

When UserA starts, let's say that only two commits were created, which we will call P and Q :

 P--Q (master) 

He then modifies FileA, the steps that change, and creates a commit that represents the new state of the source code β€” say, commit is called R This has one parent, which is a Q commit:

 P--Q--R (master) 

After successfully clicking, the commit graph for the GitHub repository looks the same.

UserB started with the same story:

 P--Q (master) 

... but created another commit called S , which has its modified version of FileB:

 P--Q--S (master) 

UserB tries to click on GitHub, but the click will be rejected - unless you "push" push, you are not allowed to update the remote branch, unless your version includes the entire history on this remote branch server. So UserB pulls out of GitHub. The tension really consists of two steps, sampling and merging. Retrieve origin/master updates that are similar to the status cache of the remote master branch from the remote origin device. (This is an example of a "remote tracking branch".)

 P--Q--S (master) \ R (origin/master) 

The story in this column diverges, so the merge tries to combine the two stories by creating a merge (for example, M ), which has both S and R as parents, and, we hope, represents the changes from both branches:

 P--Q--S--M (master) \ / \ / R (origin/master) 

When GitHub shows you a diff that represents the changes made by the commit, it is simple if it is committed with a single parent - it can just run the diff from this version. However, in the case of a commit, such as M , with multiple parents, it must select a parent to show diff. This explains why the diff shown for fixing the merge M may seem the same as that shown for one of S or R Entries in git are determined by the exact state of the source tree, and not by the changes that the tree received in this state.

+67
Aug 19 2018-11-11T00:
source share



All Articles