0

Here's what I want:

git checkout -b mybranch
<make changes>
git commit -m'changes'
git push

The branch I just created with the changes I made to exist on the remote origin. Furthermore, when I later pull, it should pull the same branch.

My current settings:

[push]
    default = current
[branch]
    autoSetupMerge = always

What do I need to do to force git to behave the way I want it to? It used to work with my current settings, now it just says "everything up to date", which clearly it is not because this branch does not exist on the remote.


Edit: Apparently pull.default isn't a valid setting, fine. So I removed it, but that's not causing the incorrect behavior anyway.

Setting push.default=upstream is DANGEROUS since now git checkout -b <newbranch> for some reason sets up where you branched from as the tracking branch. So if you're on main and create a new branch, main is the tracking branch. And push.default=upstream will merge changes to main. This is terrible behavior and bewilderingly more wrong than push.default=current.

bahamat
  • 738
  • 2
  • 9
  • 19
  • I used to use this: https://stackoverflow.com/a/1519032/818112 and now that no longer works. – bahamat May 13 '23 at 17:44
  • So fine, there's no `pull.default`, then that just gets ignored. It doesn't break anything. But `push.default=upstream` is DANGEROUS. Instead of pushing my branch to the remote, it merged to the master branch *locally*, which is fucking insane. – bahamat May 14 '23 at 02:32

1 Answers1

1

With

[push]
    default = current
    autoSetupRemote = true

git push will automatically setup the remote branch.

Ôrel
  • 7,044
  • 3
  • 27
  • 46