.gitconfig magic

Since I mostly want to push to an origin that's the same as my current branch, I can do that easily with:

git push -u origin <my_branch>

There's a also a config for that.

Kalle Tolonen
24.2.2025
Last updated on 6.11.2025

Add these lines to your .gitconfig, that's located in your home directory:

[push]
        autoSetupRemote = true

After that you can simply use:

git push

And you don't have the need to write the boilerplate.

Or just use a oneliner for it:

git config --global push.autoSetupRemote true

More tips here

https://blog.gitbutler.com/how-git-core-devs-configure-git/


Comments

No published comments yet.


Add a Comment

Your comment is held for review before it appears publicly.

Tick the box, then click Submit right away (Google expires the check after about two minutes).