brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set push.autoSetupRemote and stop typing --set-upstream

Git settings and fixes
~/tips/tip-git-push-auto-setup-remote

git config --global push.autoSetupRemote true

Makes the first push of a new branch set up tracking automatically.

You make a new branch, you push, and git answers with an error that explains how to set the upstream. We have all copied that line.

git config --global push.autoSetupRemote true

With this setting, the first git push of a new branch assumes --set-upstream. The branch is pushed to your default remote under the same name, and tracking is set up in one go. After that, a plain git pull and git push know where to go.

The docs describe it as useful if you want new branches pushed to the default remote and also want the upstream set. They say it suits central workflows where all branches have the same name on the remote.

git switch -c fix-typo
git commit -am "Fix typo"
git push

No flags, no error message, and the branch is on the remote.

The caveat is the part about names. It pushes to a branch with the same name as your local one. If you want your local branch to track something with a different name, you still have to say so yourself. It also needs a reasonably recent git; I would check git --version if the setting seems to do nothing.

Further reading: git push documentation, On this site: fetch.prune cleans up branches that no longer exist remotely, On this site: sort your branches by last commit with branch.sort

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Git settings and fixes tips git merge --abort concurrency: git rev-parse --show-toplevel git config --get-regexp '^user\.' git commit -C ORIG_HEAD All Git settings and fixes tips (40) All topics

Link