errors like this will occur when you try to push to a GitHub which you did not connected with the local repository you have in your machine. We can resolve this in a such way!
One: Delete your local repository and clone your GitHub project to your local machine($git clone ..url..) and now you can push any change directly to your GitHub account. If you do not want the original file from your local machine because you have some code on it you can move that to some where other than the directory you going to clone it. Then paste the content of your change inside newly cloned folder. Some time the issue/error may still persist so lets move to the second option.
Two: Here you mostly play with GitHub and follow this instruction since I did this many times.
From your terminal
To initialize the local directory as a Git repository
Add the files to your new local repo
commit the file
- $git commit -m "any comment you want to say"
Add the URL for the remote(GitHub) repository
- $git remote add origin ..url..
Set the new remote
Push the change
- $git push -u origin master
Now if you go to your GitHub repo you will see your change.
While pushing the terminal might say pull first bla bla ... in that case you can force your push by saying
- "$git push -f origin master"!!
Hopefully this will be helpful.