Merge codes from different authors on github

135 views Asked by At

I am new to GitHub so please excuse my dumb question. I have a repository on GitHub with 2 contributors (one is me and the other is X). I had pushed some code in the repository with say 5 files(a,b,c,d,e). Now both of us (X and me) downloaded that code and modified it.

X modified the files a,b and c and added a new file f and she committed and pushed the changes.

Meanwhile, I modified the file a and added a new file g.

Now I want to manually change the code in a, but I would like to have the repository with the files,

a(manually updated by merging changes from both me and X), b(updated by X), c(updated by X), d, e, f(added by X), g(added by me).

I hope my question is clear. Everything is in the master branch. Please tell me what steps to take. Thank you.

1

There are 1 answers

0
nwinkler On

If your changes are local only so far, and her changes are on the remote repo, you need to pull her changes into your local clone, then merge the changes (manually or automatically), then commit and then push the cleaned up repo to the remote server.

That's a standard workflow for anyone collaborating on a common repo.

So first do a git pull - this should try to automatically merge the remote changes into your local master branch. Then fix any merge conflicts using a text editor.

Once that is done, commit the local changes and follow the instructions - Git prints quite a few comments (e.g. how to abort/continue a merge).

Once everything is cleaned up, push your changes to the remote repo: git push origin master.

Long-term, you should probably start looking into using feature branches for your work. Everybody works on their own branch and only merges into master once the feature is complete. Here's a nice tutorial that compares some popular Git workflows, including how to merge incoming changes like in your case: https://www.atlassian.com/git/tutorials/comparing-workflows