Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git error when trying to push to remote branch

Tags:

git

push

I've cloned repository A's master branch from git and created my own branch called Li. I've made some changes a while ago and pushed the contents of local Li to remote Li.

Now I've pulled some updates from remote master to my local master branch and from the local master branch to the local Li, and I'm trying to push the updates from local Li to remote Li. However, when I try to run:

git checkout Li git push origin Li 

I get the following error:

error: failed to push some refs to '[email protected]:anodejs/system.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

Note that my local master branch is updated (I invoked git pull origin master) and merged into the local Li branch. I did, however, add local Li a new file, so local Li is not identical to local master (but this shouldn't matter, right?)

Thanks, Li

like image 283
user429400 Avatar asked Aug 13 '12 13:08

user429400


People also ask

Why git push is not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

How do I fix error failed to push some refs to Origin?

We can fix the error: failed to push some refs to [remote repo] error in Git using the git pull origin [branch] or git pull --rebase origin [branch] commands. In most cases, the latter fixes the error.

Which error would you get if you try to push master branch changes to a remote repository?

The error message error: refusing to update checked out branch: refs/heads/master is emitted by the remote repository and it means you're trying to push code to remote non-bare repository that has different code currently checked out in the working directory.

How do I push a new branch to a remote?

Push a new Git branch to a remote repoClone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.


1 Answers

Updates were rejected because a pushed branch tip is behind its remote.

git config --global push.default current 

Try the command above to set the current branch as default and

git push 
like image 146
Siva Kandaraj Avatar answered Sep 20 '22 15:09

Siva Kandaraj