A git push
can only fail if someone has modified the copy in Githhub before your push
(either because you have edited "online" something, or because you have done a push, before yours) . In that the push is rejected because your local copy of the repository is not updated. It is not really a conflict yet, but a mere warning that you are not up to date.
You must do a pull to update it. At that moment a conflict can be generated if what you download with pull "collides" with the local changes (you have locally modified a file that was also modified in the push). But there may also be no conflict (because remote changes do not collide with local changes), in which case git will simply mix both changes creating a new commit with the mix.
If there are conflicts instead, Git can not complete the mix without your help. You must solve the conflict by looking at the files that have "crashed" and leaving them to your liking.
Git will have introduced in these files some marks of the style <<<<<<
and >>>>>>
to delimit the lines in conflict. Between both marks a line of ======
will appear to separate the version you had locally from the remote version.
You must read those lines carefully, decide on one of the two versions (or make a mix yourself and create a new one) and eliminate all those marks. That is, you must leave that file as you would like it to be in its final version.
Once done, you will do a git add
of that file and git commit
to complete the pull that had been "interrupted" by the conflict. That will create a new local commit that saves the changes you made during the mix.
Whether there was a conflict or not, once the pull
is completed it is convenient that you make a git push
so that the remote repository also contains the commit "mix" (plus the local commits that were not yet in the remote one) ).