Autocorrect git commands

git config --global help.autocorrect 1

Divide 1 by 10, to get the time after which the the suggested command will be run. Config above sets a 0.1 second delay.

git psuh
WARNING: You called a Git command named 'psuh', which does not exist.
Continuing in 0.1 seconds, assuming that you meant 'push'.

πŸ‘†πŸ½ git push will be run automatically after 0.1 seconds.

Automatically setup remote upstream branch for a new local branch

You must have seen this a lot when pushing your new branch to remote origin (GitHub, GitLab, BitBucket and such):

git push                   
fatal: The current branch new-branch has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin new-branch

To avoid copy-pasting the set upstream command, simply setup to auto setup remote in your global config. Like so:

git config --global push.autoSetupRemote true 

Note this feature became available in git version 2.37 https://github.com/git/git/commit/05d57750c66e4b58233787954c06b8f714bbee75

Prune on Fetch

This configuration will automatically clean Git objects in your repository locally whenever you fetch changes from remote.

git config --global fetch.prune true

If this configuration is set, running git fetch will also run git remote prune afterwards. git remote prune will delete inaccessible Git objects in your local repository that aren’t on remote. Deleting branches on remote but not locally will generate these inaccessible Git objects.

Having this option enabled minimizes the number of branches I have on my local machine. Any autocomplete feature that uses this list of branches is much easier to use with limited branches hanging around.

Thanks to Andy Peterson of Atomic Object for this one. Source

Check your git config

Local (current repository)

git config --local --list

Global

git config --global --list

More details on checking and setting git config in this Stackoverflow answer.