Git

Last Updated: 9/15/2023

Fetching

  • Remote repository is hosted by GitHub in the cloud
  • Local repository is not connected to the remote repository. So if you have a new commit in the remote repository, the local repository will not be aware of that.
  • You have to use the fetch command to download the new commit. Git is going to download the new commit and then move origin/master forward.
  • Even though we downloaded the new commit, our working directory is not updated. Because currently master is pointing to the previous commit.
  • To bring the changes into master, we have to merge the other branch into master
git fetch origin branchname
or
git fetch origin
or
git fetch

git merge origin/master
  • If branches haven't diverged and we have a direct linear path from origin/master to master. So we're going to have a fast forward merge. In contrast, if our branches had diverged, potentially, we could have a conflict. So we'll have to resolve the conflict just like before.
  • To view how our local and remote tracking branches are diverging.
git branch -vv
  • To view the contents of the file
cat README.md