Home > OS >  Pulling latest repo changes to your branch
Pulling latest repo changes to your branch

Time:10-27

Hello I am bit stuck with Git.

On my remote, I have merged my recent changes.

Now on my new branch which is br/register-page, I need to pull the latest changes from my repo.

What git command should I use? git pull? or git fetch?

Please help!

CodePudding user response:

From the manual of the git pull command:

Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.

So you need git pull.

git fetch downloads the changes but do not actually merge them in your local branches, which can be useful if you have some modification to do before but want to have the latest changes on hand.

CodePudding user response:

If you have newest changes on master branch on remote, you could merge them to your existing branch locally by following commands:

git switch master
git pull
git switch br/register-page
git merge master

Or, even shorter, if you are on branch br/register-page:

git fetch origin master:master
git merge master
  • Related