PythonSOS
PythonSOS

Reputation: 359

git push -u master branch should have been git push -u origin branch

While I was pushing to my feature branch for the first time, I mistakenly pushed my commits by entering:

git push -u master feature_branch

However, to keep it consistent with other's on my team, I should have entered:

git push -u origin feature_branch

Is there any way I can change it so that it's in origin instead of master?

Upvotes: 2

Views: 132

Answers (2)

VonC
VonC

Reputation: 1323213

git push -u master feature_branch should not have worked, and trigger the error message

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

If you type git remote -v, you should see only origin.
If not:

git remote rename master origin
git remote set-url origin https://the/right/url

git push uses as argument <repository> [<refspec>…​]

master is not a repository.

So you should not have anything to fix here.

Upvotes: 0

Greg Bacon
Greg Bacon

Reputation: 139421

Examine the output of git remote -v.

Your comment on another answer suggests that you may have mistakenly renamed your origin remote. Rename it back with with

git remote rename master origin

As an alternative, you may want to discard your master remote with

git remote remove master

Although merely convention, the name master has strong association with the name of a branch and will be the source of severe confusion as the name of a remote.

Upvotes: 1

Related Questions