Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't push my code and keep getting the same error no matter what I do

I'm trying to push my code to my remote branch but keep receiving this error:

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

I think what may have caused this was the fact that I fixed a typo in my README.md on github instead of through my local environment.

I've looked all over stack overflow and tried the commands they mentioned for this problem such as git pull , git pull --rebase , git pull origin master , git push --f and many others with no avail.

I've also tried the answers in the following questions, with no success:

Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g [duplicate]

Cannot push to GitHub - keeps saying need merge

Git pull a certain branch from GitHub

I also tried git pull upstream master and I get this error:

fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
like image 287
Meikay Avatar asked Nov 07 '22 21:11

Meikay


1 Answers

Problem resolved:

I added another change and saved it in my local environment and did the following:

git stash

git pull origin <branch-name> -v

git add .

git commit

git push origin <branch-name>

like image 160
Meikay Avatar answered Nov 15 '22 12:11

Meikay