To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
git pull fetches updates for all local branches, which track remote branches, and then merges the current branch.
It says bucket-4 pushes to bucket-4
just because the default when pushing a branch is to push it to one with a matching name on the remote. (Note that this is still the default, even if the local branch is tracking a remote-tracking branch and the remote-tracking branch corresponds to a branch with a different name in the remote repository.)
The simplest way to set up the association between your bucket-4
and bucket-4
in origin
is to make sure that the next time you push, you do:
git push -u origin bucket-4
Alternatively, you can do:
git branch --set-upstream-to origin/bucket-4
To answer a couple of your questions directly:
How is it even considered "tracked" without this?
In this case it isn't - it's not tracking the remote-tracking branch in any sense if there's no branch.bucket-4.merge
or branch.bucket-4.remote
in your git config. The output from git remote show origin
is just showing you where the branch would be pushed by default.
Is there some configuration I can add in order to make all local branches track their remotes properly in the future?
I don't think that there is. When you created bucket-4
locally, as I assume happened, the remote-tracking branch didn't exist, so it can't be set up at that point - it would be very confusing default behaviour. You just need to remember to add -u
to your first git push
of that branch to its upstream repository.
I hope that's of some help.
git branch --set-upstream <branch> origin/<branch>
was deprecated at least as of 1.8.2.3 (my version).
Use git branch --set-upstream-to=origin/<branch> <branch>
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With