I have a list of commits.
abc--most recent
def
ghi
jkl
mno
pqr
stu
vwx
Now I want to remove/forget the changes from abc(most recent commit) to mno. I want to do this in local as well as remote branch (It's a seperate branch, Not master). My aim is to completely move back to the repository version pqr. Don't need backup of any changes after commit pqr.
What is easiest and safest way to avoid any further issues?
CodePudding user response:
If you want to get rid of revisions mno to abc from history:
git reset --hard mno
Careful not to have uncommitted changes laying around because they will be busted. This will require you to force-push into the remote branch.
If you want to keep history then you need a revision after abc to go back to the contents of mno:
git restore --staged --worktree --source=mno .
git commit -m "Getting content back to mno"