GIT-REMOTE(1)
๐ GIT-REMOTE(1) ๐
okay bestie, welcome to the git-remote page, straight outta the Git Manual ๐ this is the one that manages your set of tracked repositories โ aka the people (repos) you're in a situationship with.
โจ SYNOPSIS โจ
git remote [-v | --verbose]
git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <URL>
git remote rename [--[no-]progress] <old> <new>
git remote remove <name>
git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
git remote set-branches [--add] <name> <branch>...
git remote get-url [--push] [--all] <name>
git remote set-url [--push] <name> <newurl> [<oldurl>]
git remote set-url --add [--push] <name> <newurl>
git remote set-url --delete [--push] <name> <URL>
git remote [-v | --verbose] show [-n] <name>...
git remote prune [-n | --dry-run] <name>...
git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
๐ DESCRIPTION ๐
She manages the set of repositories (called "remotes", iykyk) whose branches you track. that's the whole vibe. your little black book of repos ๐โจ
๐ฆ OPTIONS ๐ฆ
-v,--verboseโ be a little more verbose, bestie: shows the remote url right after the name. and for promisor remotes, it also shows which filters (blob:noneetc.) are configured ๐. NOTE: this has to be placed betweenremoteand the subcommand โ like, position matters, no cap.
๐ COMMANDS ๐
With no arguments at all, she just shows you a list of the remotes you already have. but there are several subcommands for actually doing stuff to them ๐
๐ add
Adds a remote named <name> for the repository at <URL>. after that you can run git fetch <name> to create and update remote-tracking branches <name>/<branch> โ cute!
- With the
-foption,git fetch <name>is run immediately after the remote info is set up. instant gratification โจ - With
--tags,git fetch <name>imports every tag from the remote repository. - With
--no-tags,git fetch <name>does not import tags from the remote repository. - By default, only tags on fetched branches are imported (see
git-fetch(1)).
With the -t <branch> option, instead of the default glob refspec where the remote tracks all branches under the refs/remotes/<name>/ namespace, a refspec tracking only <branch> is created. you can hand her more than one -t <branch> to track multiple branches without grabbing all of them ๐ฏ
With the -m <master> option, a symbolic-ref refs/remotes/<name>/HEAD is set up to point at the remote's <master> branch. also peep the set-head command, they're besties.
โ ๏ธ okay so when a fetch mirror is created with--mirror=fetch, the refs are not stored in therefs/remotes/namespace โ instead, everything inrefs/on the remote gets directly mirrored intorefs/in the local repository. this option only makes sense in bare repositories, because a fetch would overwrite any local commits ๐ญ like, fr fr, careful.
When a push mirror is created with --mirror=push, then git push will always behave as if --mirror was passed. she said periodt ๐
๐ธ rename
Renames the remote named <old> to <new>. all remote-tracking branches and configuration settings for the remote get updated too ๐ซถ
In case <old> and <new> are the same, and <old> is a file under $GIT_DIR/remotes or $GIT_DIR/branches, the remote is converted to the configuration file format. glow-up moment โจ
๐ remove, rm
Removes the remote named <name>. all its remote-tracking branches and configuration settings are removed as well. it's giving blocking them ๐ซ
โญ set-head
Sets or deletes the default branch for the named remote โ that's the target of the symbolic-ref refs/remotes/<name>/HEAD. having a default branch for a remote isn't required, but it lets you specify the remote's name instead of a specific branch. for example, if the default branch for origin is set to master, then origin may be specified wherever you'd normally specify origin/master. iconic shortcut behavior ๐
- With
-dor--delete, the symbolic refrefs/remotes/<name>/HEADis deleted. - With
-aor--auto, the remote is queried to figure out its HEAD, then the symbolic-refrefs/remotes/<name>/HEADis set to the same branch. e.g., if the remote HEAD is pointed atnext,git remote set-head origin -awill set the symbolic-refrefs/remotes/origin/HEADtorefs/remotes/origin/next. โ ๏ธ this will only work ifrefs/remotes/origin/nextalready exists โ if not, it must be fetched first! - Use
<branch>to set the symbolic-refrefs/remotes/<name>/HEADexplicitly. e.g.,git remote set-head origin masterwill set the symbolic-refrefs/remotes/origin/HEADtorefs/remotes/origin/master. โ ๏ธ again, this only works ifrefs/remotes/origin/masteralready exists โ if not, it must be fetched first.
๐ง set-branches
Changes the list of branches tracked by the named remote. this is how you track a subset of the available remote branches after the initial setup for a remote โ very curated of you ๐
The named branches get interpreted as if they were specified with the -t option on the git remote add command line.
- With
--add, instead of replacing the list of currently tracked branches, she adds to that list. more is more ๐
๐ get-url
Retrieves the URLs for a remote. configurations for insteadOf and pushInsteadOf are expanded here. by default, only the first URL is listed.
- With
--push, push URLs are queried rather than fetch URLs. - With
--all, all URLs for the remote are listed. all of them. the whole collection ๐ฆ
๐ฅ set-url
Changes URLs for the remote. sets the first URL for remote <name> that matches regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. if <oldurl> doesn't match any URL, an error occurs and nothing is changed ๐
- With
--push, push URLs are manipulated instead of fetch URLs. - With
--add, instead of changing existing URLs, a new URL is added. - With
--delete, instead of changing existing URLs, all URLs matching regex<URL>are deleted for remote<name>. โ ๏ธ trying to delete all non-push URLs is an error.
๐ important bestie: the push URL and the fetch URL, even though they can be set differently, must still refer to the same place. what you pushed to the push URL should be what you'd see if you immediately fetched from the fetch URL. if you're trying to fetch from one place (e.g. your upstream) and push to another (e.g. your publishing repository), use two separate remotes. don't make it weird.
๐ซถ show
Gives you some information about the remote <name>. spill the tea โ
- With the
-noption, the remote heads are not queried first withgit ls-remote <name>; cached information is used instead. no cap, it's faster.
๐ prune
Deletes stale references associated with <name>. by default, stale remote-tracking branches under <name> are deleted, but depending on global configuration and the configuration of the remote, we might even prune local tags that haven't been pushed there. equivalent to git fetch --prune <name>, except that no new references will be fetched.
See the PRUNING section of git-fetch(1) for what it'll prune depending on various configuration.
- With the
--dry-runoption, she reports what branches would be pruned, but does not actually prune them. window shopping ๐๏ธ
๐ง update
Fetches updates for remotes or remote groups in the repository as defined by remotes.<group>. if neither group nor remote is specified on the command line, the configuration parameter remotes.default is used; if remotes.default isn't defined, all remotes which do not have the configuration parameter remote.<name>.skipDefaultUpdate set to true will be updated. (See git-config(1)).
- With the
--pruneoption, run pruning against all the remotes that are updated. two birds, one stone ๐ช
๐ DISCUSSION ๐
The remote configuration is achieved using the remote.origin.url and remote.origin.fetch configuration variables. (See git-config(1)). that's the whole lore drop ๐
โญ EXIT STATUS โญ
- On success, the exit status is
0. slay ๐ - When subcommands such as
add,rename, andremovecan't find the remote in question, the exit status is2. - When the remote already exists, the exit status is
3. - On any other error, the exit status may be any other non-zero value.
๐ EXAMPLES ๐
- Add a new remote, fetch, and check out a branch from it
$ git remote
origin
$ git branch -r
origin/HEAD -> origin/master
origin/master
$ git remote add staging git://git.kernel.org/.../gregkh/staging.git
$ git remote
origin
staging
$ git fetch staging
...
From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
* [new branch] master -> staging/master
* [new branch] staging-linus -> staging/staging-linus
* [new branch] staging-next -> staging/staging-next
$ git branch -r
origin/HEAD -> origin/master
origin/master
staging/master
staging/staging-linus
staging/staging-next
$ git switch -c staging staging/master
...
- Imitate
git clonebut track only selected branches โ the โจcuratedโจ clone experience
$ mkdir project.git
$ cd project.git
$ git init
$ git remote add -f -t master -m master origin git://example.com/git.git/
$ git merge origin
๐ฆ SEE ALSO ๐ฆ
git-fetch(1) ยท git-branch(1) ยท git-config(1) โ go read those next, bestie, they're literally so good ๐ซถ
๐ GIT ๐
Part of the git(1) suite ๐
and that's the whole page, bestie! ๐ this was Git 2.56.0, dated 2026-09-27 โ mwah, go forth and remote responsibly โจ๐
๐ฆ where this page comes from
- arch rolling: git 2.56.0-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms