Pregunta

Me and a friend are working on a small project hosted on Github. Neither of us are very experienced (clearly).

I submitted a pull request that was successfully merged however, my friend did not update his local repository to include these latest changes.

When my friend next did a push, he overwrote all of my changes.

How can I retain most (excluding conflicts) of my edits and his?

I tried making a branch based on my last commit, and then merging said branch with the master branch however doing so did not work because because the master branch was said to be "up to date" and now I am lost.

¿Fue útil?

Solución

The best way to resolve this issue would be to do a fetch followed by a merge or a rebase. I would suggest a rebase to keep your history linear and clean.

fetch updates your copy of the remote branch while not touching your own branch. A git pull will effectively do a fetch followed by a merge.

The command chain to resolve your problem would look like this

git fetch
git rebase origin/master master
# ... Solve conflicts ... (continue the rebase with 'git rebase --continue')
git push

If your friend commited during the time you were resolving the conflicts you should do a git pull --rebase before pushing. But git will tell you about this, when you try to push, so I wouldn't worry about it until it screams at you.

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