Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to pull the master changes from my branch?

Tags:

git

I am working on a 3 branch project.

I am on branch1, and there is master branch.

When I need to pull and merge something from master:

git checkout master
git pull origin master
git checkout branch1
git merge master

is there a way to pull the master changes from my branch so I don't have the needed to do merge ?

something like:

git pull origin master

but from branch1 without switching to master branch.

EDIT

Resume:

I have 3 branches: every time there is something new in master, I don't want to switch to branch master. All I want is to pull the master new features into my branch, without going to the master branch.

like image 547
Non Avatar asked Mar 16 '23 00:03

Non


2 Answers

You may want to use rebase, so that you can merge your master changes onto your branch you are working

git fetch origin            # Updates origin/master
git rebase origin/master    # Rebases current branch onto origin/master

Also check out this question

Update: Recent Git versions provide a simpler way to do the equivalent of the above two commands.

git pull --rebase origin master
# where --rebase[=(false|true|merges|preserve|interactive)]
like image 162
ThanosFisherman Avatar answered Mar 18 '23 13:03

ThanosFisherman


From your working folder with branch1 checked out:

git fetch
git merge origin/master

The fetch downloads changes from the remote repo to your machine, but does not apply them to your working folder. The merge applies what you just downloaded to your working folder (whichever branch you are currently on)

like image 20
Andy Joiner Avatar answered Mar 18 '23 12:03

Andy Joiner