Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: same remote upstream for two local branches

Tags:

git

I have two local branches, master and dev When I write git branch -v I get

master    f83fskr [origin/master: ahead 2] some commit message
def       kfdsj42 other commit message

I want both branches to have origin/master as their upstream branch, so that it will show

master    f83fskr [origin/master: ahead 2] some commit message
def       kfdsj42 [origin/master: ahead 3] other commit message

And also so that I could use git pull, git push without specifying a branch.

How can I achieve this? (-u didn't work)

like image 448
Dotan Avatar asked Apr 05 '26 19:04

Dotan


1 Answers

Checkout to def branch and set-upstream-to (-u) origin/master branch. Now, git push, git pull commands should work.

$ git checkout def
$ git branch -u origin/master
like image 169
Sajib Khan Avatar answered Apr 08 '26 15:04

Sajib Khan



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!