0

I have code in 2 environments, UAT and PROD. Say I make a copy of the UAT code and put it on the UAT branch, and likewise for PROD. When doing a PR from UAT to PROD, I'd want to see the differences between the two (they are mostly the same, but there are a few things in UAT that are not in PROD yet). But git says there's nothing to compare because they're different histories. Which is true.

Is there a way to remedy this so I can see the differences and start promoting code from UAT to PROD via git?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Frankie
  • 11,508
  • 5
  • 53
  • 60
  • Does [this](https://stackoverflow.com/questions/1968512/getting-the-difference-between-two-repositories) relate/help with your situation? – mnestorov Apr 28 '21 at 17:51

1 Answers1

1

Your PROD code should be in the main branch. Then create and checkout a new branch from main, let's say import/UAT.

On the import/UAT branch, do a file diff , not a git diff against the code in your existing UAT branch. You may need to copy those files to another location to do the file comparison. I'd use something like Beyond Compare. You can copy/commit those changes into import/UAT.

Now you'll have your git history between the two environments.

While on import/UAT you can do a git diff main --name-only to see a list of file names that have changed and work from there.

Update:

If you do a file compare with a good tool, you can bulk copy all changes from the source UAT folder to the folder containing your repo on import/UAT. Then you can bulk add all changes in one command.

git add .
git commit -m "UAT changes."

You can even try just copying the existing UAT files into the repo folder while you have import/UAT checked out. git will most likely figure out file deltas and additions regardless of the file's timestamp.

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44
  • I get what you're doing here with the branching. But does this require manually applying the content from uat to import/uat, for each changed file one by one? Or maybe just as tedious, finding the last commit for each file on uat and applying it to import/uat? Other ideas? – Frankie Apr 28 '21 at 19:18
  • Manually can be one at a time or in bulk. Updated. – Adrian J. Moreno Apr 28 '21 at 19:39