0

Our project uses master as our "production" branch and staging as our "testing" branch. The normal flow of operations we desired was for developers to make changes on their development branches (branched off staging) and then merge into staging when they are done. We then do Integration type testing on the staging branch. If everything passes we wanted to then merge staging into master. In theory, staging and master shouldn't be too different than each other.

Our first shot at trying this, we got into a state where master had changes that staging did not, and vice-a-versa.

The way we solved this was we merged master into staging (fixing all the merge conflicts) and then merged staging into master (fixing all the merge conflicts).

If I do a

git compare <hash from master after merge from stagin>..<hash from staging after merge from master>

it returns nothing. I take this to mean that all the files are the same. This is what we expected.

However, if I use ... then it returns a ton of stuff.

GitLens (a git extension for VSCode) says the same:

enter image description here

Now every attempt to merge staging into master has a bunch of stuff, not just the changes that have been made since the last merge. However I don't believe most of the stuff are actually file differences.

To make maters worse, we have pushed changes into staging since the initial merging.

What do I need to do to go about fixing this?

lr100
  • 648
  • 1
  • 9
  • 29
  • 1
    Did you always use a "true merge" (merge commit) or did you use any options like "squash merge" or "rebase and fast-forward"? – IMSoP Sep 21 '22 at 17:21
  • We did it through gitlab and I think we squashed the commits. Would that create a problem? Sorry. Pretty new at this. – lr100 Sep 21 '22 at 18:07
  • 1
    Yes, squash merges should never be used to take changes from a branch you aren't immediately throwing away. A "squash merge" isn't really a merge at all, but a strange artificial commit that throws away all the history you've carefully created (can you guess I'm not a fan?) See [git merge squash and recurring conflicts](https://stackoverflow.com/questions/11797904/git-merge-squash-and-recurring-conflicts) and https://stackoverflow.com/questions/63862271/github-still-shows-differences-between-branches-after-sucessfull-merge/63864551 and many others. – IMSoP Sep 21 '22 at 20:04
  • Ah ok. I thought this was a "clean" way of doing it. Would merging master into staging and then staging into master (with out squashing) fix all of this? or did I royally screw it up. – lr100 Sep 21 '22 at 21:37
  • One of the linked answers has a suggestion of how to recover things; I haven't tried it myself, but it looks logical. – IMSoP Sep 22 '22 at 07:21

0 Answers0