I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?
I know I can just edit the
To avoid remembering what you need to do each time you get the message:
Please specify which branch you want to merge with. See git-pull(1)
for details.
.....
You can use the following script which sets origin as upstream for the current branch you are in.
In my case I almost never set something else than origin as the default upstream. Also I almost always keep the same branch name for local and remote branch. So the following fits me:
#!/bin/bash
# scriptname: git-branch-set-originupstream
current_branch="$(git branch | grep -oP '(?<=^\* )(.*)$')"
upstream="origin/$current_branch"
git branch -u "$upstream"