Skip to content

Instantly share code, notes, and snippets.

@richxcame
Last active May 17, 2022 17:37
Show Gist options
  • Save richxcame/42682ea2af5675e4496531750e87460f to your computer and use it in GitHub Desktop.
Save richxcame/42682ea2af5675e4496531750e87460f to your computer and use it in GitHub Desktop.
Get cheat sheet

Config username for git

git config --global user.name "John Doe"

Config email for git

git config --global user.email [email protected]

Config default editor for git

git config --global core.editor vim

Config default branch name

git config --global init.defaultBranch main

Show config list of git

git config --list

Show git status

git status

Show logs

git log

Show logs shorten

git log --oneline

Delete local merged branch

git branch -d localBranchName

Delete local unmerged branch

git branch -D localBranchName

Delete remote branch

git push origin --delete remoteBranchName

Synchronize branch list

git fetch -p

Show all branchs

git branch --all

Show remote url

git remote -v

Discard uncommited changes

git checkout -- .

Accept all their changes without solving conflicts

git checkout --theirs .
git add .

Remove cached file

git rm --cached .env

Remove entire git cached

git rm -r --cached .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment