Course Tonight

Course Tonight

Did You Know?

Advanced visual search system powered by Ajax

Chapter 45: Git Remote

Estimated reading: 4 minutes 5 views
Parameter Details
-v, –verbose Run verbosely.
-m <master> Sets head to remote’s <master> branch.
–mirror=fetch Refs will not be stored in refs/remotes namespace, but instead will be mirrored in the local repo.
–mirror=push git push will behave as if --mirror was passed.
–no-tags git fetch <name> does not import tags from the remote repo.
-t <branch> Specifies the remote to track only <branch>.
-f git fetch <name> is run immediately after remote is set up.
–tags git fetch <name> imports every tag from the remote repo.
-a, –auto The symbolic-ref’s HEAD is set to the same branch as the remote’s HEAD.
-d, –delete All listed refs are deleted from the remote repository.
–add Adds <name> to list of currently tracked branches (set-branches).
–add Instead of changing some URL, new URL is added (set-url).
–all Push all branches.
–delete All urls matching <url> are deleted (set-url).
–push Push URLs are manipulated instead of fetch URLs. The remote heads are not queried first with git ls-remote <name>, cached information is used instead.
-n Dry-run: report what branches will be pruned, but do not actually prune them.
–prune Remove remote branches that don’t have a local counterpart.

Section 45.1: Display Remote Repositories

To list all configured remote repositories, use git remote. It shows the short name (aliases) of each remote handle that you have configured.

$ git remote
premium
premiumPro
origin

To show more detailed information, the --verbose or -v flag can be used. The output will include the URL and the type of the remote (push or pull):

$ git remote -v
premiumPro https://github.com/user/CatClickerPro.git (fetch)
premiumPro https://github.com/user/CatClickerPro.git (push)
premium https://github.com/user/CatClicker.git (fetch)
premium https://github.com/user/CatClicker.git (push)
origin https://github.com/ud/starter.git (fetch)
origin https://github.com/ud/starter.git (push)

Section 45.2: Change remote URL of your Git repository

You may want to do this if the remote repository is migrated. The command for changing the remote URL is:

git remote set-url

It takes 2 arguments: an existing remote name (origin, upstream) and the URL.

Check your current remote URL:

git remote -v
origin https://bitbucket.com/develop/myrepo.git (fetch)
origin https://bitbucket.com/develop/myrepo.git (push)

Change your remote URL:

git remote set-url origin https://localserver/develop/myrepo.git

Check your remote URL again:

git remote -v
origin https://localserver/develop/myrepo.git (fetch)
origin https://localserver/develop/myrepo.git (push)

Section 45.3: Remove a Remote Repository

Remove the remote named <name>. All remote-tracking branches and configuration settings for the remote are removed.

To remove a remote repository named dev:

git remote rm dev

Section 45.4: Add a Remote Repository

To add a remote, use git remote add in the root of your local repository.

For adding a remote Git repository <url> as an easy short name <name>, use:

git remote add <name> <url>

The command git fetch <name> can then be used to create and update remote-tracking branches <name>/<branch>.

Section 45.5: Show more information about remote repository

You can view more information about a remote repository by git remote show <remote repository alias>.

git remote show origin

Result:

remote origin
Fetch URL: https://localserver/develop/myrepo.git
Push URL: https://localserver/develop/myrepo.git
HEAD branch: master
Remote branches:
master tracked
Local branches configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
master pushes to master (up to date)

Section 45.6: Rename a Remote Repository

Rename the remote named <old> to <new>. All remote-tracking branches and configuration settings for the remote are updated.

To rename a remote branch named dev to dev1:

git remote rename dev dev1

Leave a Comment

Share this Doc

Chapter 45: Git Remote

Or copy link

CONTENTS