Reputation: 809
I followed vogella tutorial about GIT, section 17 exercice "Working with (local) remote repository". when executing step 17.3, I got this error :
The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream ../remote-repository.git master
The steps executed are:
$repo01>git clone --bare . ../remote-repository.git
Cloning into bare repository '../remote-repository.git'...
done.
$mkdir repo02
$\repo02>git clone ../remote-repository.git .
Cloning into '.'...
done.
$\repo01>git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test01
modified: test02.txt
no changes added to commit (use "git add" and/or "git commit -a")
$repo01>git commit -a -m "Some changes"
$\repo01>git push ../remote-repository.git
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 ../remote-repository.git master
What can be the reason?
Upvotes: 4
Views: 407
Reputation: 14449
As git tells you: The current branch master has no upstream branch.
Thus, git does not know to which branch of your remote-repository
it is supposed to push your changes.
I can not reproduce this; if I execute your steps, the upstream branch is set. However, to fix this you can do exactly what git tells you: git push --set-upstream ../remote-repository.git master
. This tells git that the branch you're currently working on (your local master
) pulls from and pushes to the master
branch of your remote-repository by default. If this is once set, push will automatically know where to push to in the future.
Did you do anything else than the commands you provided in your question?
Edit: I probably cannot reproduce this because of my custom settings of push.default
: I would advice to set it to current with $ git config --global push.default current
. This means that git pushes only the current branch and automatically pushes to a remote branch with the same name if it exists. See here at the push.default
section for details.
Upvotes: 4
Reputation: 756
git push origin master
origin is your remote git branch name, master is your local branch.
Upvotes: -1