Git Cheatsheet
Initial Date: 2025-03-19
Status:🪴Sprout (Work in Progress)
Basics
To fetch a remote branch from GitHub:
git fetch <remote> <branch>
How to clone a private repo using your personal access token (GitHub):
git clone https://<token>@github.com/<your account or organization>/<repo>.git
How to check and update git credentials for any repository:
git config --list
git config user.name "My Name"git config user.email "myemail@email.com"
How to delete a folder
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.
git ls-remote --get-url <origin|remote-name>
How to obtain more information about the remote repo
git remote show <origin|remote-name>
How to get a list of all remotes URLs
git remote -v
How to remove a remote you no longer need
git remote remove <remote-name>
Commits
How to fix a commit message gone wrong
git commit --amend -m "correct commit message"