Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: If I push a new branch to origin, how to make it tracking automatically [duplicate]

Tags:

git

I created a new local branch and pushed it with

git push origin my-branch

How can I automatically set up my local branch to tag the just created remote branch?

Or do I always need

git branch --set-upstream my-branch  origin/my-branch
like image 433
Alex Avatar asked Jul 26 '12 15:07

Alex


People also ask

How do I create a new branch and push it to Origin?

Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch. Simply use a git push origin command on subsequent pushes of the new branch to the remote repo.

Does git push push automatically branch?

If you run the simple command git push , Git will by default choose two more parameters for you: the remote repository to push to and the branch to push. By default, Git chooses origin for the remote and your current branch as the branch to push.

How do I track my upstream branch?

You can check tracking branches by running the “git branch” command with the “-vv” option. We can set the upstream branch using the “git push” command. $ git push -u origin branch Total 0 (delta 0), reused 0 (delta 0) * [new branch] branch -> branch Branch 'branch' set up to track remote branch 'branch' from 'origin'.

What is remote tracking branch in git?

Remote-tracking branches are references to the state of remote branches. They're local references that you can't move; Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository.


1 Answers

You can use git push -u origin my-branch. This will set-up everything for argument-less push/pull.

like image 136
pmr Avatar answered Sep 30 '22 21:09

pmr