Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Get changes from remote repo – GitHub

Summary

To get the latest changes from your remote repo, enter the following command in your terminal:

git fetch origin

Details

The above command will retrieve the latest changes from all of your branches on your remote repo but will not merge any changes into your local branches. Merging the changes requires one more step.

Merging fetched changes

As an example, let’s say you want to merge your changes that you fetched from the remote master branch into your local master branch. After using the git fetch origin command above, you can view the list of commits in your remote master branch by entering the following command in your terminal:

git log --oneline origin/master

Before using the git merge command, make sure you are on the master branch by using the git branch or git status command. If not, use the following command to switch:

git checkout master

To merge the changes from origin/master into master, enter the following command in your terminal:

git merge origin/master

You can see all of the new commits added to master by entering the following command:

git log --oneline master

The above example was for the master branch, but you can use the same steps with any local branch and its remote counterpart.

Exercises

Use the commands from the Summary and Details section to get the changes from your remote repository.

References

Working with Remotes from the Pro Git book

Back to: GitHub Reference