I messed up my app and winded up doing a
git checkout <commit number>
to get back at the place where I would like to be.
when I do a git status, it says
Your branch is behind 'origin/master' by 5 commits, and can be fast-forwarded.
I guess I'm on the 5th from my latest commit. Is there a way to make my 5th from latest commit my most recent one? pretty much to override or discard everything from my first four commits?
UPDATE.
I did a
git reset --hard <commit number>
but how can I push to my repository? it says...
To prevent you from losing history, non-fast-forward updates were rejected
I don't want to perform a merge, I pretty much want to wipe out my latest 4 commits
thanks
You can always force a push with the -f
option:
git push -f origin master
but of course beware because this will destroy history.
Also make sure to specify both remote and branch name because without it, by default git will try and force push all branches to the given (or upstream) remote.
git reset --hard <commit number>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With