Key points
- Git has two mechanisms for synchronization: pushing and pulling.
git push takes your local commits and synchronizes the remote repository with those commits.
git pull brings the commits from the remote repository and merges them with your local commits.
// push the remote main branch to local
git push origin master
git pull is actually two commands in disguise: git fetch and git merge.
// pull the changes from the remote into your local
git pull origin
git fetch pulls all of the commits down from the remote repository to your local one.
git merge merges the commits from the remote into your local repository.
git checkout <our_branch_name>
git merge <their_branch_name>
- You can’t push to a remote that has any commits that you don’t have locally, and that Git can’t fast-forward merge.
- You can pull commits from multiple remotes into your local repository and merge them as you would commits from any other branch or remote.
- Check the remote that this git links to
git remote -v
git remote add <remote_name> <remote_url>