Skip to content

Git Cheatsheet

Initial Date: 2025-03-19
Status:🪴Sprout (Work in Progress)


Basics

To fetch a remote branch from GitHub:

Terminal window
git fetch <remote> <branch>

How to clone a private repo using your personal access token (GitHub):

Terminal window
git clone https://<token>@github.com/<your account or organization>/<repo>.git

How to check and update git credentials for any repository:

Terminal window
git config --list
Terminal window
git config user.name "My Name"
git config user.email "myemail@email.com"

How to delete a folder

Terminal window
rm -rf <folder-name>

Remotes

How to get the remote URL of a repo.

In this case the remote is called origin, but works with other cases changing the name.

Terminal window
git ls-remote --get-url <origin|remote-name>

How to obtain more information about the remote repo

Terminal window
git remote show <origin|remote-name>

How to get a list of all remotes URLs

Terminal window
git remote -v

How to remove a remote you no longer need

Terminal window
git remote remove <remote-name>

Commits

How to fix a commit message gone wrong

Terminal window
git commit --amend -m "correct commit message"