Advertisement
Advertisement


Updating a local repository with changes from a GitHub repository


Question

I've got a project checked locally from GitHub, and that remote repository has since had changes made to it. What's the correct command to update my local copy with the latest changes?

2019/04/09
1
580
4/9/2019 12:02:34 AM

Accepted Answer

Probably:

git pull origin master
2019/04/09
811
4/9/2019 12:02:45 AM

This should work for every default repo:

git pull origin master

If your default branch is different than master, you will need to specify the branch name:

git pull origin my_default_branch_name
2016/04/27

git fetch [remotename]

However you'll need to merge any changes into your local branches. If you're on a branch that's tracking a remote branch on Github, then

git pull

will first do a fetch, and then merge in the tracked branch

2009/09/18

This question is very general and there are a couple of assumptions I'll make to simplify it a bit. We'll assume that you want to update your master branch.

If you haven't made any changes locally, you can use git pull to bring down any new commits and add them to your master.

git pull origin master

If you have made changes, and you want to avoid adding a new merge commit, use git pull --rebase.

git pull --rebase origin master

git pull --rebase will work even if you haven't made changes and is probably your best call.

2018/02/21

With an already-set origin master, you just have to use the below command -

git pull "https://github.com/yourUserName/yourRepo.git"
2019/04/09

Source: https://stackoverflow.com/questions/1443210
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]