Skip to content

How to synchronize local repository with the latest version on Github

Isaac Kwan edited this page Sep 15, 2017 · 5 revisions

Warning: Keep a local copy of your current version or commit it to your personal repository as this method will overwrite all files in your local repository.


Whether you are using Github desktop or git, if you ever come across situations where you cannot fetch the origin as the master branch files were updated, here is a simple method you can use if you simply want to get the latest files from any branch in your Github repository without saving your local changes.

Sample error message with git checkout on Mac Terminal

Steps to replace all local files

  1. Install Git on your computer
  2. Go to the directory of the Github folder
  3. Run the following command: git reset --hard HEAD
  4. Now, you will have the latest files downloaded from your branch on Github. All the old files are overwritten.

Reference: Screen capture of the above steps with Mac Terminal

  • Sample repository name: FreeCodeCampHongKong.github.io

Clone this wiki locally