Reputation: 6707
Every time, when I want to push, I use this command:
$ git push
And it throws this error:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
And the error will be gone when I use this command:
$ git push origin master
Ok, I can always use this ^ command, but I want to knon, can I say to git, {when I say push
, I mean push origin master
} once forever?
Upvotes: 0
Views: 45
Reputation: 118021
Once you give your local branch an upstream
git push --set-upstream origin master
then after that, the following will "just work"
git push
You only have to do the first command if the remote branch does not already exist.
To check if you are already tracking a remote branch you can type
git branch -vv
Then it will list something like
master abcd123 [origin/master] Some commit message
Then you can see that your local master
branch is tracking the remote origin/master
branch.
Upvotes: 0
Reputation: 927
or you can use short version of this notation:
git push --set-upstream origin <REMOTE_NAME>
git push -u origin <REMOTE_NAME>
git needs to know which remote branch you are trying to push your code to.
Upvotes: 1