0

how solving the rejected push of only-a-file push to replace its remote counterpart on github ?
Try this https://happygitwithr.com/push-rejected.html without any success

e.g. message

 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/abdulbadii/MatrixMultiplier'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details
  • 1
    "hint: Updates were rejected _because the remote contains work that you do not have locally_. This is usually caused by another repository pushing to the same ref. You may want to _first integrate the remote changes_." "hint: See the 'Note about fast-forwards' in _'git push --help'_ for details" – knittl Sep 06 '21 at 05:33
  • 1
    PS pushes are always about _commits_ and _never_ about file(s). – knittl Sep 06 '21 at 05:53

1 Answers1

0

it seems like someone else working on the same git branch, so just stash your modifications using git stash

and then run git pull origin branch_name and then to get your changes , run git stash pop

after that push your code

Rishni Meemeduma
  • 324
  • 3
  • 14