0
commit 6e01a486911547e4854d738efe0bd060ff46f3d1 (HEAD -> staging, origin/staging)
Author: Josh
Date:   Fri Mar 5 09:58:07 2021 +0800

    Added room sub-module link

commit d0188817d1b15d3c301e69974495ca4bae2ec005
Author: Josh
Date:   Fri Mar 5 09:24:07 2021 +0800

    Added room sub-module link

commit 0cc722ad9ff73ba8102591e206029aa1032f14a9
Author: Jake
Date:   Wed Mar 3 14:28:09 2021 +0700

    added tab

commit 5e290bfbe3ce9ea2ad2931e67d2d377220e01f9d
Author: Jake
Date:   Wed Mar 3 08:33:10 2021 +0700

   translations

How to remove/replace as a new the previous push on the gitlab.

What I tried is to

git reflog then

git reset d018881 then

git add .

git commit -m 'Added room sub-module link'

git push origin staging

  • I don't think "push" is the right term. Are you referring to commits? – Dai Mar 05 '21 at 02:19
  • @Dai What I did just shortcut. I complete on it. –  Mar 05 '21 at 02:21
  • Probably this is what the answer you're looking for ?https://stackoverflow.com/questions/8903953/how-to-revert-last-commit-and-remove-it-from-history – Kovalan R Mar 05 '21 at 02:27

1 Answers1

1

Technically speaking, if you want to undo the latest commit on a branch which you have published, and which someone else might already have pulled, you should use git revert rather than resetting:

# from staging
git revert 6e01a486
# now make your new commit and push
git add .
git commit -m 'Added room sub-module link'
git push origin staging

If you really did want to nuke the latest commit, then use a hard reset followed by a force push:

# from staging
git reset --hard HEAD~1
# now make your new commit and push
git add .
git commit -m 'Added room sub-module link'
git push --force origin staging
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360