I was trying to use git and git-hub for my first time;
and there was a file that I wanted to change it's name so I just changed it and committed then when I pushed it but it says :
[rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/MyUserName/MyProjectName.git' 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.
so I just added -f
to force but it made another directory holding the old name of the file so I delete it but every time I do push
command it just makes the same thing
how can I get rid of this old file once and for ever thanks.
CodePudding user response:
You need to pull the latest version of the GitHub repository before pushing local changes.
git pull
After this make the changes you wish to make on the local repository (Changing the file name in this case)
Then :-
git commit -am "Message"
git push