Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I squelch "fatal: The upstream branch of your current branch does not match the name of your current branch"?

Tags:

git

There is a related question on SO dealing with how to change the parameters of the push command to avoid this message:

fatal: The upstream branch of your current branch does not match the name of your current branch

I'm interested in how to squelch the message itself, without changing the names of my local/remote branches or using fancy push commands.

Suppose I have a local branch tracking a remote branch of a different name:

user@home:~ git branch -vv
branch-name abcd1234 [remote/origin/branch-name] last commit message

Now I want to be able to push my commited changes by simply typing git push. When I do this, I get the following message:

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:remote/origin/branch-name

To push to the branch of the same name on the remote, use

    git push origin branch-name

How do I force git to automatically push to the upstream branch even if the names don't match? I'm using git 1.9.1

like image 537
quant Avatar asked Jan 10 '23 18:01

quant


1 Answers

Newer Git (v 1.9 or newer)

git config --global push.default upstream

Older Git

git config --global push.default tracking

Git 2.3 still accepts tracking as a synonym for upstream

Just do that once and whenever you "git push" it will push your current branch to its configured upstream.

This also sets it in your global config, which might be shadowed by a different setting in your repository config.

like image 198
Andrew C Avatar answered Jan 25 '23 12:01

Andrew C