Skip to content

Instantly share code, notes, and snippets.

@huksley
Last active August 11, 2022 04:49
Show Gist options
  • Save huksley/ef70da85f8dc0c9ca6f8ec4f37c3a637 to your computer and use it in GitHub Desktop.
Save huksley/ef70da85f8dc0c9ca6f8ec4f37c3a637 to your computer and use it in GitHub Desktop.
Add this to bashrc for superpowerful git
# 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
}
@huksley
Copy link
Author

huksley commented Jul 31, 2022

Make ~/.bashrc easily editable by adding alias bashrc="${EDITOR:-nano} ~/.bashrc && source ~/.bashrc"

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