Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: merge hides certain changes

We work through the visual studio 2015 with git. We have had central repository (GitLab) with single branch 'master'. Two people have cloned repository.

  1. First guy have added "test-new-file-v.txt" file in the solution. It have changed solution file (.sln) and have changed string "VisualStudioVersion = 14.0.23107.0". Then he commit in your local repository and then push this commit in central repository (GitLab). After that, we have watched this commit in the central repository (GitLab): enter image description here

  2. Second guy have added "testgit.txt" file in the solution. It have changed solution file (.sln) too, but didn`t change string VisualStudioVersion. Then he want to pull central repository (GitLab) before push.

  3. Second guy has had conflict. He merge through the visual studio 2015 and see that different guy have made mistake in changing "VisualStudioVersion = 14.0.24720.0" on "VisualStudioVersion = 14.0.23107.0". Second guy want to leave string "VisualStudioVersion = 14.0.24720.0" unchanged. He chose local state "VisualStudioVersion = 14.0.24720.0" for this string and make commit merge. After that he push this two commits in the central repository (GitLab).
  4. After that, we have watched history and changes in the central repository (GitLab) and have seen that commit merge from second guy: enter image description here

We see that in the central repository (GitLab) solution file contains string "VisualStudioVersion = 14.0.24720.0" and this is correct, but we don`t see that this string replace string "VisualStudioVersion = 14.0.23107.0", because commit from first guy contains this string and be before merge commit.

My questions:

  1. Is it correct behaviour? I expect to see in the merge commit that string "VisualStudioVersion = 14.0.23107.0" changed to "VisualStudioVersion = 14.0.24720.0".
  2. How can i achieve behaviour in which I can see all the changes?
like image 358
sribin Avatar asked Oct 31 '22 11:10

sribin


1 Answers

  1. I am assuming he didn't get your changes before his commit on the master branch, so locally he may not have a change that would be pushed. This prevents code being reverted if your branch is out of date.

  2. I would suggest not committing changes to master. Create separate local branch and use pull requests into master.

Look into using git branching strategy to keep your branches orderly.

Git Branching Model

like image 89
AndrewK Avatar answered Nov 15 '22 06:11

AndrewK