Skip to content

Instantly share code, notes, and snippets.

@kabilashgit
Created May 12, 2020 06:56
Show Gist options
  • Save kabilashgit/e228e2b4d7d80349a5d8f6f570210ae3 to your computer and use it in GitHub Desktop.
Save kabilashgit/e228e2b4d7d80349a5d8f6f570210ae3 to your computer and use it in GitHub Desktop.

Git necessary configs

$ git config --global user.name "my name"
$ git config --global user.email "my name"

# That way, you avoid any automatic transformation.
# Set autocrlf to false when you do only windows-only projects, otherwise `warning: LF will be replaced by CRLF.`
$ git config --global core.autocrlf false

# set autocrlf to avoid warning when you switch the OS for project)
# This happens when you pull and all files were executable in the remote repository. Making them executable again will set everything back to normal again.
$ git config --global core.filemode false

# https://stackoverflow.com/questions/21181231/server-certificate-verification-failed-cafile-etc-ssl-certs-ca-certificates-c
$ git config --global http.sslverify false

# Permanently authenticating with Git repositories. https://stackoverflow.com/questions/8588768/how-do-i-avoid-the-specification-of-the-username-and-password-at-every-git-push
$ git config --global credential.helper store

Usefull aliases

git config --global alias.st "status"
git config --global alias.b "branch"
git config --global alias.adl "add ."
git config --global alias.cm "commit -m"
git config --global alias.cam "commit -am"
git config --global alias.co "checkout"
git config --global alias.con "checkout -b"
git config --global alias.cp "cherry-pick"
git config --global alias.sp "stash pop"
git config --global alias.last "log -n 1"
git config --global alias.ln1 "log --numstat -1"             # shows what all files affected in last commit
git config --global alias.lg 'log --pretty=format:"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]" --graph --decorate'       # shows all commit hash,msg, user in graph format
git config --global alias.lgn 'log --pretty=format:"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]" --graph --decorate --numstat'      # shows all commit hash,msg, user, numstat in graph format
git config --global alias.sl "stash list"
git config --global alias.sp "stash pop"
git config --global alias.r "reset HEAD"
git config --global alias.r1 "reset HEAD^"
git config --global alias.r2 "reset HEAD^"
git config --global alias.rh1 "reset HEAD^ --hard"
git config --global alias.rh2 "reset HEAD^^ --hard"
git config --global alias.pom "push -u origin master"
git config --global alias.po "push -u origin"

Another awesome git aliases - https://gist.github.com/robmiller/6018582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment