Pregunta

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.

¿Fue útil?

Solución

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 hisRemote

2. Then create a new branch with only the changes you made, that is branched off of where you committed the original changes.
git branch myChanges

3. Reset the master branch back to the commit where you committed the original changed
git checkout master
git reset --hard <commitOriginalChangesAreIn>

4. Then merge his branch with his changes and the original changes into that branch.
git merge hisRemoteBranch

5. Finally merge that branch tip into the branch with your changes.
git merge myChanges

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top