Note I posted this question on askubuntu, but I wasn't getting an answer.I saw this post on meta, so I thought I would try posting on SO.
So I have initialized a git repository based on an existing repository on Github. The project I am initiating is very different than the latest commit listed for the repository.
When I tried to executer this set of commands
git init
git remote add origin https://github.com/account/repo
git fetch origin
git add -A
git commit -m "message"
git push origin master
I get the following error:
To https://github.com/account/repo
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/account/repo'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
The thing is, I know that there a differences between this repository and origin, but I explicitly do not want to pull the latest changes from the repository. I want to override the changes on Github with the ones in this repository.
Is there anyway to do this? Is there anyway to force a push even with the fast-forwarding error?
Thank you for any help or guidance.
EDIT: Would The answer by Adam Dymitruk on this question work, or did the order in which I executed the above commands have screwed up his method?