Advertisement

List Remote Repositories

Show configured remote repositories.

git remote

Show remote URLs:

git remote -v

Add a Remote Repository

Add a new remote repository.

git remote add <name> <url>

Example adding origin:

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

Remove a Remote

Remove a remote repository.

git remote remove <name>

Rename a Remote

Rename a remote repository.

git remote rename <old-name> <new-name>

Change Remote URL

Update the URL of a remote repository.

git remote set-url <name> <new-url>

Show Remote Information

Display detailed information about a remote.

git remote show <name>

Example:

git remote show origin

Fetch from Remote

Download objects and refs from remote repository.

git fetch

Fetch from specific remote:

git fetch <remote-name>

Fetch all remotes:

git fetch --all

Fetch and prune deleted remote branches:

git fetch --prune

Pull from Remote

Fetch and merge changes from remote.

git pull

Pull from specific remote and branch:

git pull <remote> <branch>

Pull with rebase:

git pull --rebase
Advertisement

Push to Remote

Upload local commits to remote repository.

git push

Push to specific remote and branch:

git push <remote> <branch>

Push and set upstream:

git push -u origin <branch>

Force push (use with caution):

git push --force

Safer force push:

git push --force-with-lease

Push All Branches

Push all local branches to remote.

git push --all origin

Push Tags

Push all tags to remote.

git push --tags

Push specific tag:

git push origin <tag-name>

Delete Remote Branch

Delete a branch from remote repository.

git push origin --delete <branch-name>

Clone with Specific Branch

Clone and checkout a specific branch.

git clone -b <branch> <url>

Track Remote Branch

Set up local branch to track remote branch.

git branch --set-upstream-to=origin/<branch>
Last updated: January 2026
Advertisement