I'm following a tutorial on how to use Git. I'm up to the part where I am to push files to a newly created GitHub repo. However I am getting the error:
Updates were rejected because the remote contains work that you do not have locally.
So I deleted that file. However I still cannot push. I'm still getting the same message.
That deletion has created a new commit that you don't have locally.
The issue is not the presence or absence of files, it is the presence of different history (set of commits) between your local repo and the remote repo.
Set your local configuration with:
git config --global pull.rebase true git config --global rebase.autoStash true
Any local work in progress will be stashed, your own commits rebased, your work re-applied. You can then review, add, commit and push.
That combination (
rebase.autostash) is available since Git 2.6 (Sept. 2015): see "Can “
git pull” automatically stash and pop pending changes?"