Question

What should I do in git if I've found myself wanting to return to an earlier version in my history, and commence editing from there? (i.e., make some earlier version to the forefront and start committing/pushing to it)? Doing git reset --hard HEAD~1 will take me back in time to previous versions, but what do I do once I've found the version I want? If I try to do a git push from this position, it tells me

error: failed to push some refs to 'https://github.com/thinkpad20/router.git'
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.

But I don't want to pull the remote changes -- I don't want anything but the version I have now.

Was it helpful?

Solution

You should push harder:

git push --force

This will overwrite the remote branch with what you have locally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top