Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete commit on gitlab

Tags:

git

gitlab

How can I delete a commit that I made on GitLab? This commit that I made is not the HEAD now.

If I can't delete it, can I edit?

When it was the HEAD, I tried:

git reset  --soft HEAD  git reset  --soft HEAD^1  git revert HEAD  git rebase -i HEAD  git rebase -i HEAD~1  git reset --hard HEAD  git reset --hard Id-Code 

I already tried to rebase it, but it still stays on the branch. Now I just removed it from the HEAD, but it is still there.

There is another command?

like image 634
mhery Avatar asked Oct 25 '16 17:10

mhery


People also ask

Can I delete commits from GitLab?

then loop these steps : update the repository contents with git filter-repo. upload the modified contents. cleanup dangling references When this is done, the Gitlab project will be purged of all references to those old commits.

How do I delete a specific commit?

do the revert (or use git rebase -i <something before the bad commit> <temporary branch> to remove the bad commit) redo the merge. rebase your subsequent work back on: git rebase --onto <temporary branch> <old merge commit> <real branch> remove the temporary branch.

Can I delete my commit?

You can simply remove that commit using option "d" or Removing a line that has your commit. In the latest git version there is no more option d.


1 Answers

  1. git reset --hard CommitId
  2. git push -f origin master

1st command will rest your head to commitid and 2nd command will delete all commit after that commit id on master branch.

Note: Don't forget to add -f in push otherwise it will be rejected.

like image 171
ABHAY JOHRI Avatar answered Nov 06 '22 05:11

ABHAY JOHRI