Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull updates from remote branch

There is remote branch: R

There is local branch: L (which was created based on R)

So the graph is

 R--R1---R2---  
 \           
  L--L1--

Right now, I just need keep L branch always have the updates from R

What is the simplest way I can do this?

I think the answer is to:

  1. pull updates from local R first
  2. checkout to L and merge

But this does not seem very straightforward and I need do some conflict handling manually.

like image 710
Forrest Avatar asked Nov 20 '25 14:11

Forrest


2 Answers

You want to make L a tracking branch for R. You can do this with the command.

git branch --track L remote/R

Then, any time you are on branch L, just run git pull remote and it will pull updates and automatically merge them into your repository.

https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches

like image 60
haydenmuhl Avatar answered Nov 23 '25 10:11

haydenmuhl


You can pull directly into L from R. Assuming L is checked out:

git pull origin R

L doesn't have to be tracking branch for you to pull in remote changes.

like image 42
ralphtheninja Avatar answered Nov 23 '25 08:11

ralphtheninja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!