0

This is my master branch on gitlab. I want to undo the previous commit as master is not working now.

Using terminal, I should switch to master branch and then:

git revert f23...

enter image description here

This is the pipeline for more information and I want to go back to the arrow:

enter image description here

Sana
  • 463
  • 2
  • 4
  • 22
  • 2
    Well, if you ware going to mask some information from a picture, what's the point if you can read them anyway? You want to `git revert @^^^`? – KamilCuk Oct 21 '20 at 13:20
  • [Does this help?](https://stackoverflow.com/questions/927358/how-do-i-undo-the-most-recent-local-commits-in-git/927386#927386) – isherwood Oct 21 '20 at 13:23
  • `revert` and `reset` are very different things. – matt Oct 21 '20 at 14:12
  • @KamilCuk I am not sure what is the best approach. do you recommend something else other than revert? – Sana Oct 21 '20 at 15:24
  • I do not believe a "recommendation" is possible - that solely depends on what _you_ want to do - if you want to _revert_ the commit or _reset_ current head to that commit. That's different. – KamilCuk Oct 21 '20 at 15:25

1 Answers1

2

you can try with

git reset --soft "HEAD~3"

this will remove your first 3 commits. Next you can run:

# remove the staged files
git restore --staged .

# remove the changed files
git checkout -- . 

Now do some change and run:

# add your change
git add .

# commit the change
git commit -m "my change"

# force the push and replace the history
git push -f
LeoLopez
  • 296
  • 3
  • 8