Skip to content

Instantly share code, notes, and snippets.

@boydc7
Last active November 2, 2023 17:47
Show Gist options
  • Save boydc7/8ea931d5be30152d1b6e230bc8ab1a68 to your computer and use it in GitHub Desktop.
Save boydc7/8ea931d5be30152d1b6e230bc8ab1a68 to your computer and use it in GitHub Desktop.
Reasonable git defaults
# push relevant tags when pushing branches
git config --global push.followTags true
# Make git pull do a --recurse-submodules flag on each pull
git config --global submodule.recurse true
# Make git push do an on-demand try of pushing sub-modules before pushing main repos
git config --global push.recurseSubmodules on-demand
# push only current branch on a push
git config --global push.default simple
# FF only on pull
git config --global pull.ff only
# checkout as is, commit as is
# git config --global core.autocrlf false
# Page in a separate console window only if the page of info is longer than the term window
git config --global --replace-all core.pager "less -F -X"
# prune stale remotes on fetch (all fetch operations)
git config --global fetch.prune true
# pc only...if you want it
# git config --global core.editor notepad
# default to tracking checkout branches to their remote counterpart, even when creating a local branch
git config --global branch.autoSetupMerge always
# Rebase by default on a pull
git config --global branch.autosetuprebase
# Turn paged output off
git config --global pager.branch false
# Use default merge message on ff merges
git config --global core.mergeoptions --no-edit
git config --global clean.requireForce false
# diff / merge
git config --global diff.submodule log
git config --global mergetool.keepBackup false
git config --global merge.tool bc3
git config --global mergetool.bc3.trustExitCode true
git config --global diff.tool bc3
# git config --global mergetool.bc3.path 'c:/program files/beyond compare 4/bcomp.exe'
# git config --global difftool.bc3.path 'c:/program files/beyond compare 4/bcomp.exe'
# aliases
git config --global alias.remotes 'remote -v'
git config --global alias.pruneo '!git remote prune origin'
git config --global alias.prunel '!'"f() { git branch --v | egrep \"\[gone\] \" | awk '{print \$1}' | xargs git branch -d; };f"
git config --global alias.up '!git remote update -p; git merge --ff-only @{u}'
git config --global alias.revertall 'reset --hard'
git config --global alias.resetall 'reset --hard'
git config --global alias.remove rm
git config --global alias.shelve stash
git config --global alias.unshelve 'stash pop'
git config --global alias.deshelve 'stash pop'
git config --global alias.unstash 'stash pop'
git config --global alias.destash 'stash pop'
git config --global alias.stat status
git config --global alias.branches 'branch -a'
git config --global alias.shelveall '!'"git submodule foreach 'git stash || true'; git stash"
git config --global alias.stashall '!'"git submodule foreach 'git stash || true'; git stash"
git config --global alias.unshelveall '!'"git submodule foreach 'git stash pop || true'; git stash pop"
git config --global alias.deshelveall '!'"git submodule foreach 'git stash pop || true'; git stash pop"
git config --global alias.unstashall '!'"git submodule foreach 'git stash pop || true'; git stash pop"
git config --global alias.destashall '!'"git submodule foreach 'git stash pop || true'; git stash pop"
git config --global alias.cloneall 'clone --recurse-submodules'
git config --global alias.statall '!'"git status; git submodule foreach 'git status'"
git config --global alias.addall '!'"git submodule foreach 'git add --all . || true'; git add --all ."
git config --global alias.checkoutall '!'"git checkout \"\$1\"; git submodule foreach \"git checkout \"\$1\" || true\"; #"
git config --global alias.checkoutball '!'"git checkout -b \"\$1\"; git submodule foreach \"git checkout -b \"\$1\" || true\"; #"
git config --global alias.commitall '!'"git submodule foreach \"git commit -a -m \"\$1\" || true\"; git commit -a -m \"\$1\"; #"
git config --global alias.pullm '!'"f() { gcb=\$(git symbolic-ref --short HEAD); git checkout master; git pull; git checkout \$gcb; };f"
git config --global alias.pullmm '!'"f() { gcb=\$(git symbolic-ref --short HEAD); git checkout master; git pull; git checkout \$gcb; git merge --ff-only master; };f"
git config --global alias.mergeall '!'"git submodule foreach \"git merge \"\$1\" || true\"; git merge \"\$1\"; #"
git config --global alias.pushall '!'"git submodule foreach 'git push || true'; git push"
git config --global alias.pullall '!'"git submodule foreach 'git pull || true'; git pull"
git config --global alias.pushball '!'"git submodule foreach \"git push origin --set-upstream \"\$1\" || true\"; git push origin --set-upstream \"\$1\"; #"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment