I know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad
git reset --hard 41651df8fc9
I've made quite some changes, I've made some commits and now that I'm trying to push all these commits into the server I get the following error:
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]'
Git suggests to do a git pull and that's what other people have suggested to other users. However, I believe that a git pull will merge my current code with the code that I don't want anymore (head revision). How can I do a push and forget about the version/revisions ahead of me?
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.
This means that someone else pushed a commit to the same branch you're pushing to, but you don't have that commit on your laptop yet. This can happen if it has been awhile since you ran "git pull" on a branch that many people contribute to, such as staging. To fix this issue, run: git pull origin <your-branch>
Under Account settings, click on the Developer settings tab. Select Personal access tokens from the left tab. Select the Scope of access you want the token to have to your GitHub account. REMEMBER to copy your personal access token someplace SAFE!
git push -f
if you have permission, but that will screw up anyone else who pulls from that repo, so be careful.
If that is denied, and you have access to the server, as canzar says below, you can allow this on the server with
git config receive.denyNonFastForwards false
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