Git - Remote branch

About

A remote branch is a branch in a remote repository. (remote reference).

Type

Management

List

git branch -r -l '<remote>/<pattern>'

git branch --remotes
# or
git remote show [remote]

Example:

git remote show origin
* remote origin
  Fetch URL: https://github.com/apache/spark.git
  Push  URL: https://github.com/apache/spark.git
  HEAD branch: master
  Remote branches:
    branch-0.5      tracked
    branch-0.6      tracked
    branch-0.7      tracked
    branch-0.8      tracked
    branch-0.9      tracked
    branch-1.0      tracked
    branch-1.0-jdbc tracked
    branch-1.1      tracked
    branch-1.2      tracked
    branch-1.3      tracked
    branch-1.4      tracked
    branch-1.5      tracked
    branch-1.6      tracked
    branch-2.0      tracked
    branch-2.1      tracked
    branch-2.2      tracked
    branch-2.3      tracked
    master          tracked
  Local branches configured for 'git pull':
    branch-2.3 merges with remote branch-2.3
    master     merges with remote master
  Local refs configured for 'git push':
    branch-2.3 pushes to branch-2.3 (up to date)
    master     pushes to master     (up to date)

where:

Delete

git push --delete <remote> <branchname>

Prune

git remote prune

Pull

To get the commit from a remote branch, you do a pull (ie a git fetch followed by git merge FETCH_HEAD)

Fetch (Sync information locally)

A fetch will get new branch information locally (ie branch created on the remote)

Example:

git fetch
From https://github.com/name/repoName
 * [new branch]      dev        -> origin/dev

To get the data in the local branch, you need to merge and if you want to do all in one move, you can just use pull


Powered by ComboStrap