I have a project that’s using git. When I received the repo, it had some uncommitted changes. I committed those, and started making my own.
I received work from another developer, and that developer committed both their changes and the original uncommitted changes into a single commit.
Now I have two git repos in separate folders and I’d like to know how I can merge my changes into the developers changes with as few conflicts as possible.
Assuming you have your tip currently checked out, and it is
master, one option would be to:1. Add a remote from your repository pointing to theirs.
2. Fetch in his changes
git fetch hisRemote2. Then create a new branch with only the changes you made, that is branched off of where you committed the original changes.
git branch myChanges3. Reset the
masterbranch back to the commit where you committed the original changedgit checkout mastergit reset --hard <commitOriginalChangesAreIn>4. Then merge his branch with his changes and the original changes into that branch.
git merge hisRemoteBranch5. Finally merge that branch tip into the branch with your changes.
git merge myChanges