Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git commands & settings
  6. Remote Git commands
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Remote Git commands


Copy repository

$ git clone <url>

The clone command will create a copy of an existing remote repository on your local machine. It will also configure a local repository to track the remote repository automatically.

That configuration allows you to execute the Git push command or the Git fetch/ pull commands without specifying the remote repository name.

See:

Add remote repository

$ git remote add <name>

Show list of remote repositories

$ git remote

If you add a -v option, you can see the details of the remote repositories.

Checkout branches from remote repository

$ git checkout <branch>

The checkout command creates a branch in your local repository based on a branch in the remote repository that you have already fetched.

See:

Create & push branch changes to remote repository

$ git push <repository> <refspec>

The push command creates a branch in the remote repository and pushes changes from the local repository. You must specify the remote repository and the branch to push to.

The -u option to the push command will allow Git to add a tracking reference to the remote repository when the local branch is successfully pushed. You will not have to specify the repository parameter the next time you do a push/fetch/pull.

See:

Inspect branch changes in remote repository

$ git fetch <repository> <refspec>

The fetch command lets you retrieve the latest data from your remote repository to inspect changed content. This command, however, does not automatically merge the changes into any of your existing work.

The repository and refspec parameters are optional. Omitting a repository name will yield the same operation as a push command. Omitting the refspec parameter will ensure fetch is applied to all branches in that remote repository.

Get & merge latest branch changes from remote repository

$ git pull <repository> <refspec>

The pull command will retrieve the latest changed content from the remote repository and merge it directly into your local repository. Basically, “pull = fetch + merge.”

The repository and refspec parameters are optional. Omitting a repository name will yield the same operation as a push command. Omitting the refspec parameter will ensure that the pull only applies to the current branch.

See:

Delete branches from remote repository

$ git push --delete <repository> <branchname>

Delete a branch in a remote repository.

Add the --delete option to the push command to delete the specified branches from the remorse repository.

Create tags in remote repository

$ git push <repository> <tagname>

If you add the --tags option, all tags that exist in the local repository will be pushed and created in the remote repository together with any symbolic reference you specified in place of <tagname>.

Delete tags from remote repository

$ git push --delete <repository> <tagname>

Use the --delete option to the push command to delete the specified tags from the remote repository.

Change address of remote repository

$ git remote set-url <name> <newurl>

Change the address of an existing remote repository to that specified in <newurl>.

Rename remote repository

$ git remote rename <old> <new>

Change the name of an existing remote repository from <old> to <new>.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life