Git Update & Publish Commands[Cheatsheet]

Luka
2 min readMar 2, 2020
https://github.blog/2019-01-07-new-year-new-github/

There are not very many commands in Git that access the network, nearly all of the commands operate on the local database. When you are ready to share your work or pull changes from elsewhere, there are a handful of commands that deal with remote repositories.

List all current configured remotes:

$ git remote -v

Show information about a remote:

$ git remote show <remote>

Add new remote repository, named <remote>:

$ git remote add <remote> <url>

Rename a remote repository, from <remote> to <new_remote>:

$ git remote rename <remote> <new_remote>

Remove a remote:

$ git remote rm <remote>

Note: git remote rm does not delete the remote repository from the server. It simply removes the remote and its references from your local repository.

Download all changes from <remote>, but don’t integrate into HEAD:

$ git fetch <remote>

Download changes and directly merge/integrate into HEAD:

$ git remote pull <remote> <url>

Get all changes from HEAD to local repository:

$ git pull origin master

Get all changes from HEAD to local repository without a merge:

$ git pull --rebase <remote> <branch>

Publish local changes on a remote:

$ git push remote <remote> <branch>

Delete a branch on the remote:

$ git push <remote> :<branch> (since Git v1.5.0)

OR

$ git push <remote> --delete <branch> (since Git v1.7.0)

Publish your tags:

$ git push --tags

--

--

Luka

Software Engineer with a focus on building interactive and impactful applications. JS, React, Ruby on Rails.