Last active
August 11, 2022 04:49
-
-
Save huksley/ef70da85f8dc0c9ca6f8ec4f37c3a637 to your computer and use it in GitHub Desktop.
Add this to bashrc for superpowerful git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Default globals for git | |
git config --global user.name "My name" | |
git config --global user.email "[email protected]" | |
git config --global credential.helper 'cache --timeout 360000' | |
git config --global push.default current | |
git config --global pull.default current | |
# If you have multiple GitHub accounts that you use for different repositories | |
git config --global credential.useHttpPath true | |
function git() { | |
if [[ "$@" == "" ]]; then | |
command git status && command git remote -v && command git show-branch --list | |
elif [[ "$@" == "zip" ]]; then | |
command git archive --format=zip HEAD -o $(basename $PWD).zip --verbose | |
elif [[ "$@" == "uncommit" ]]; then | |
command git reset --soft HEAD~1 | |
elif [[ "$@" == "pushall" ]]; then | |
command git push --all origin | |
elif [[ "$@" == "pull" ]]; then | |
BRANCH=`command git symbolic-ref --short HEAD` | |
echo Pulling from origin $BRANCH | |
command git pull origin $BRANCH | |
elif [[ "$1" == "config" ]]; then | |
command git "$@" | |
elif [[ "$@" == "diff" ]]; then | |
command git diff --ignore-space-at-eol -- . ':(exclude)package-lock.json' ':(exclude)yarn-lock.json' | |
else | |
command git "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make ~/.bashrc easily editable by adding
alias bashrc="${EDITOR:-nano} ~/.bashrc && source ~/.bashrc"