Check where you're in the log history Command to this step -> "git log --oneline --all --graph" Assign a new branch to track the remote branch Command to this step -> "git branch branch_name origin/remote_branch_name" After that, check your log history either using the step 3 command or "git branch"
There is a command that gives you about all tracking branches. And to know about the pull and push configuration per branch you can use the command git remote show origin. and you can use -sb option for seeing the upstream. Hope this information will help you to find which branch is tracking.
line 1: 'git branch -r' (followed by 'git remote update' to update the info on changes to remote) lists all remote branches; 'egrep -vw' is used to knock entries having HEAD and master in the result. line 3: Track the named remote branch while checking it out locally.
git fetch
git branch --track branch-name origin/branch-name
First command makes sure you have remote branch in local repository. Second command creates local branch which tracks remote branch. It assumes that your remote name is origin
and branch name is branch-name
.
--track
option is enabled by default for remote branches and you can omit it.
If you don't have an existing local branch, it is truly as simple as:
git fetch
git checkout <remote-branch-name>
For instance if you fetch and there is a new remote tracking branch called origin/feature/Main_Page
, just do this:
git checkout feature/Main_Page
This creates a local branch with the same name as the remote branch, tracking that remote branch. If you have multiple remotes with the same branch name, you can use the less ambiguous:
git checkout -t <remote>/<remote-branch-name>
If you already made the local branch and don't want to delete it, see How do you make an existing Git branch track a remote branch?.
First of all you have to fetch the remote repository:
git fetch remoteName
Than you can create the new branch and set it up to track the remote branch you want:
git checkout -b newLocalBranch remoteName/remoteBranch
You can also use "git branch --track" instead of "git checkout -b" as max specified.
git branch --track newLocalBranch remoteName/remoteBranch
When the branch is no remote branch you can push your local branch direct to the remote.
git checkout master
git push origin master
or when you have a dev branch
git checkout dev
git push origin dev
or when the remote branch exists
git branch dev -t origin/dev
There are some other posibilites to push a remote branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With