Search code examples
githubgit-pushgit-pull

I have a question about using github with collaborators


I guys, Id like to know some tips about git, I've worked with collaborators in the same repository and Id like to know if when someone makes the code's push, the code that is already there will be changed adding only the changes and when the other persor make the other git-push the code will be the union of both pushes, or the code will be replaced by the last one pushed from the last person who made the git-push.


Solution

  • The second person making a push won't be able to, unless he/she forces the push (git push --force), assuming they are both pushing from and to the same branch.

    The best practice would be for that second person to do first:

    git pull --rebase
    

    That will replay unpushed commit on top of the update branch (with the commits from the first person). Possible merge conflicts will be resolved locally, in the second person's local Git repository.

    Then a simple git push will add the new commits on top of the existing ones.