Reputation: 3246
Long time ago I clone the project from remote server.Recently I mostly worked on one particular branch of this project. Now I need to push the changes to this branch only (not to master).
I think I can do this with command
git push origin localBranchName:remoteBranchName
Also I can add -u
to track this remote branch. But i might be tracking already so my question is how can I make sure I am tracking remote branch from this local branch. Is there git command or option that I can use?
Upvotes: 0
Views: 126
Reputation: 2856
Just use git status
(reference: http://git-scm.com/docs/git-status)
git status
will show desired information for the branch you currenly on.
Example output:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
In this example local branch master
tracks branch master
on remote origin
You may also find useful shorter version: git status -sb
which will output:
## master...origin/master
if you branch tracks the remote
## master
if it is not.
Upvotes: 3
Reputation: 4900
As noted in another answer, git branch
offers a way to print out the upstream branch for a local branch. That information is also stored in .git/config
in the section for the branch. For example, for branch "myniftybranch" tracking upstream "origin/foo", you will find a section in .git/config
that looks like this:
[branch "myniftybranch"]
remote = origin
merge = refs/heads/foo
Hope that helps.
Upvotes: 1
Reputation: 2485
You could use the -vv
(very verbose) flag of git branch
:
$ git branch -vv
Which will list all local branches, along with their default tracking branch.
Upvotes: 4