LinuxCommandLibrary

git-remote

Manage tracked remote repositories

TLDR

List existing remotes with their names and URLs

$ git remote [[-v|--verbose]]
copy

Show information about a remote
$ git remote show [remote_name]
copy

Add a remote
$ git remote add [remote_name] [remote_url]
copy

Change the URL of a remote (use --add to keep the existing URL)
$ git remote set-url [remote_name] [new_url]
copy

Show the URL of a remote
$ git remote get-url [remote_name]
copy

Remove a remote
$ git remote remove [remote_name]
copy

Rename a remote
$ git remote rename [old_name] [new_name]
copy

SYNOPSIS

git remote [-v | --verbose] [subcommand args]
git remote add [<options>] <name> <url>
git remote rename <old> <new>
git remote rm <name>
git remote show [<-n>] <name>

PARAMETERS

-v, --verbose
    Show remote names and URLs

--dry-run
    Dry run for prune/update

add
    Add remote with name and URL

-t <branch>
    Track specific branch on add

-m <master>
    Set upstream branch mapping on add

-f
    Fetch immediately after add

--tags
    Fetch all tags on add

--no-tags
    Disable tag fetching on add

rename
    Rename remote

-f
    Rename local refs on rename

rm, remove
    Delete remote

set-head
    Set or delete default HEAD branch

-a
    Auto-detect HEAD branch

-d
    Delete HEAD ref

set-branches
    Configure tracked branches

--add
    Add branch without removing others

set-url
    Change remote URL

--push
    Modify push URL

--add
    Add new URL

--delete
    Delete specific URL

show
    Display remote info

-n
    No HEAD resolution on show

prune
    Prune stale refs

-n
    Dry-run prune

update
    Fetch updates from remotes

-p, --prune
    Prune during update

--jobs=<n>
    Parallel jobs for update

DESCRIPTION

git remote is a versatile Git porcelain command for managing remote repositories, which are named references to other Git repositories, typically on remote servers for collaboration via push and pull operations.

It enables adding new remotes with URLs, renaming or removing existing ones, configuring tracking branches, displaying remote details including URLs and branches, pruning stale refs, and updating remotes by fetching changes.

Remotes store fetch and push URLs, tracked branches, and tags configuration in .git/config. Common workflows include setting an 'origin' remote for the canonical upstream repo, adding upstream for contributors, or mirrors for backups.

Subcommands like add, rm, rename, show, prune, and update streamline repository synchronization. Options allow verbose output, dry-runs, and specific branch/tag handling, making it essential for multi-repo projects.

COMMON USAGE

git remote add origin https://github.com/user/repo.git
Adds default origin remote.

git remote -v
Lists all remotes.

git remote prune origin
Removes deleted remote branches.

CONFIGURATION STORAGE

Remotes stored in [remote "<name>"] sections of .git/config or git config --global for shared settings.

HISTORY

Introduced in Git 1.6.0 (2008) as porcelain frontend to plumbing like git-ls-remote and config manipulation. Evolved with subcommands like set-url (1.6.6), update (1.7.0), and parallel fetching (2.4.0). Central to Git's distributed workflow since core development by Linus Torvalds and contributors.

SEE ALSO

Copied to clipboard