Part 06: Update your remote repository.
You have learned most of the Git now, and you can literally do almost everything locally, but have you ever thought, how to update your things on Github?
The best way is to use the “Push” method.
Using the Push method
Follow us through the code here:
git push origin main
It will ask you the passphrase, if you had one, and a few seconds later, github will quickly update!
Use Pull or Fetch method to avoid differences
Sometimes it will say: Failed to push some refs to origin/main
What shall we do now?
You can use the code:
git fetch origin main
git merge origin/main
You can also use
git pull origin main
If nothing is wrong, then you are done! You can now git push origin main
again!
Use diff method to solve differences if failed to pull or merge
Use the code:
git fetch origin main
git diff main origin/main