I started using git to track my customizations to a 3rd party web app. I interface with consultants that have been using git to track their changes for a while. I’ll try to make this easy to understand.
- I have a copy of an export from one of our environments
- I started a repository using the export as a base [LOCAL] and have been committing to it regularly
- The consultants have their own repository that is up to date (excludes my changes) [3RDPARTY]
- I’ve forked their git repo [REMOTE]
Now from here all I want to do is go through and merge all the files that are different between [LOCAL] and [REMOTE].
I don’t care about the branches or history I currently have in LOCAL. I only care about using REMOTE from now on and sending/receiving pull requests to interact with the consultants.
How do you recommend I can do this? I tried creating a new branch on LOCAL and overwriting all the files with the updated files from 3RDPARTY. Then I was hoping a merge between that new branch and my regular dev branch would give me a conflict so I could easily merge them all with KDiff3 but instead it just automerged and overwrote all my changes instead.
You tried to copy all the files over and just get a merge but it didn’t work. That should work, but I think you may need to follow some different steps which I’ll try to explain.
There should be a tag, or checking in
3RDPARTYthat was identical to a checkin point in your export environment which is the first checkin toLOCAL. I will call this checkinMERGE_BASE. So try these steps:git checkout masteronREMOTEand make sure it isup to date with
3RDPARTYwithgit pull origin.REMOTEgit branch mergeb <MERGE_BASE><MERGE_BASE>is thecheckin I spoke about in the history that is identical, or as close
as identical, to what you would have in your initial creation of
LOCAL.LOCALdirectlyover top the files in your
mergebbranch we just created inREMOTE. DONOT copy the .git directory!REMOTEon branchmergebusegit addto make sure all yourchanges are applied to the git index and then run
git commit. Nowyour
REMOTEmergebbranch should have identical source to what isin
LOCAL. (you could use git remotes to do this with your LOCALchanges, but since you don’t care about history I recommend just
doing it this way to simplify the process).
git checkout master.them.. do
git checkout -b remote_work.mergebbranch into yourremote_workbranchwith
git merge --no-ff mergeb. At this point you will probablyhave all the conflicting merges with their work and your work to
resolve.
Once you finish this process and commit the work to your branch you should be now in the exact state you wanted.
After all of this, if you want all your work to appear as if you started with what is currently in
3RDPARTYwhile on theremote_workbranch onREMOTEsimply dogit rebase master.From then on out I would keep master on
REMOTEsynced with their3RDPARTYrepo and keep your changes which hasn’t been pulled into3RDPARTYin theremote_workor other various branches on theREMOTErepo.Let me know if this process works out for you.