.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
Feb. 24, 2025
Last updated on Nov. 6, 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 may be published.