Skip to content

Instantly share code, notes, and snippets.

@AndrewSavetchuk
Last active February 25, 2023 06:04
Embed
What would you like to do?

Configure Git Username/Email

Globally

git config --global user.name "FirstName LastName"
git config --global user.email "mail@example.com"

# To verify the global configuration, run:
git config --list

Locally

# Locally (per repo)
git config user.name "FirstName LastName"
git config user.email "mail@example.com"

# To verify the local configuration, run:
cat .git/config

Configure Git Aliases

# To display the list of aliases you currently have, run:
git config --get-regexp alias

# To remove an alias, run:
git config --global --unset alias.aliasName

#––––––––––––––––––––––––––––––––––––––––––

# Alias 1 (Git status)
#
# Usage: git st
git config --global alias.st status

#––––––––––––––––––––––––––––––––––––––––––

# Alias 2 (Stage all changes and commit)
#
# Usage: git adc -m "Commit message"
git config --global alias.adc '!git add -A && git commit'

#––––––––––––––––––––––––––––––––––––––––––

# Alias 3 (Show history)
# 
# Usage example: git lol
# Usage example: git lol -5
git config --global alias.lol 'log --graph --decorate --pretty=oneline --abbrev-commit'

Configure Git Aliases in .bash_profile

nano ~/.bash_profile

alias gb="git branch"
alias gc="git checkout"
alias gp="git pull"
alias gs="git status"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment