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
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With