---
name: "cg-branch-add"
section: "1"
platform: "linux"
package: "cogito"
version: "0.18.2-1"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/cg-branch-add"
---

# cg-branch-add(1)

add new remote branch

## NAME

cg-branch-add - add new remote branch

## SYNOPSIS

cg-branch-add BRANCH\_NAME LOCATION.sp

## DESCRIPTION

Takes the desired branch name and source location as parameters..sp This command lets you add to the list of *remote branches*. Those are branches in your local repository which correspond to some branches in other repositories..sp After you add a remote branch, you can [**cg-fetch**(1)](/cg-fetch/1.md) from it to get the latest changes on the branch, as they appeared in the remote repository..sp Terminology note: This command concerns remote branches, not the local ones (those managed by [**cg-switch**(1)](/cg-switch/1.md))..sp The possible source location specifiers are:.sp

- 1\.

  Local path - note that fetching will hardlink the objects if possible.

- 2\.

  rsync - rsync://host/path THE rsync REPOSITORY ACCESS METHOD IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE! The problem is that it will download \_all\_ data from the remote repository, including objects which do not belong to the one particular branch you want to fetch.

- 3\.

  HTTP - http://host/path

- 4\.

  HTTPS - https://host/path

- 5\.

  FTP - *ftp://host/path*

- 6\.

  SSH - git+ssh://host/path or host:path (the latter can change); note that the path must be absolute in the first case.

- 7\.

  git daemon - git://host/path The URL can have a fragment part, which identifies a branch inside of the remote repository (in the form "repoURL#branchname"). Otherwise, Cogito defaults to whatever branch the repository's HEAD points to at the time of each fetch..sp

## OPTIONS

- \-h, --help

  Print usage summary.

- \--long-help

  Print user manual. The same as found in [**cg-branch-add**(1)](/cg-branch-add/1.md).

## FILES

$GIT\_DIR/branches/BRANCH\_NAME

Contains the source location of the remote branch.

$GIT\_DIR/refs/heads/BRANCH\_NAME

Contains pointer to the latest commit in a branch. It can be more conveniently retrieved using cg-object-id BRANCH\_NAME.

## EXAMPLE USAGE

Let's say you have a repository at git+ssh://host/path/repo.git and you want to fetch its *testing* branch to your local repository. In that case you can do.sp

```
$ cg-branch-add repo-testing 'git+ssh://host/path/repo.git#testing'
```

and refer to it as *repo-testing* anytime later:.sp

```
$ cg-fetch repo-testing
```

For example you can check the changes in the repo-testing branch compared to your current branch:.sp

```
$ cg-diff -r repo-testing
```

## COPYRIGHT

Copyright © Petr Baudis, 2005.sp

## SEE ALSO

cg-branch-add is part of [**cogito**(7)](/cogito/7.md), a toolkit for managing [**git**(7)](/git/7.md) trees..sp
