Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

‘fatal: No destination configured to push to’ error when I do a 'git push'

Tags:

git

I try to checkout a remote branch.

And then make a commit and then push.

I get fatal: No destination configured to push to error when I do a 'git push'.

Here is the sequence of commands I use:

$ git checkout remote/test-1.6
$ git checkout -b test-1.6
$ git commit -a -m "commit message"
$ git push
fatal: No destination configured to push to.

Thank you.

like image 716
michael Avatar asked Oct 06 '11 22:10

michael


People also ask

Why git push is not working?

It may be possible that push permission is not provided to the user pushing the code changes. I suggest checking the user permissions. If the push permission is present, then it may be possible that there is a pre-push git hook in the repo and your push isn't in accordance with it.

How do I force a git push?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the <refspec>... section above for details. Force an update only if the tip of the remote-tracking ref has been integrated locally.

Why can't I push code to GitHub?

To push a branch on remote, your branch needs to have the latest changes present in remote repository. If you get the failed to push error, first do git pull the branch to get the latest commits and then push it.


1 Answers

You probably already have a remote for your repository, but your new branch hasn't been configured to use it. This should work:

git push --set-upstream remote test-1.6

Having done that once, there is now a tracking branch in place and you can simply use "git push" in future -- assuming you've configured upstream push of the current branch as the default, like so:

git config --global push.default tracking

Or (preferred) as of git 1.7.4:

git config --global push.default upstream
like image 160
yoyo Avatar answered Oct 29 '22 11:10

yoyo