How to delete gitlab commits [duplicate]

0

Is it possible to delete gitlab commits using git commands?

I have already tried through the visual studio of the > Team Explorer but unsuccessful

    
asked by anonymous 23.01.2018 / 10:17

2 answers

3

You can try to rewrite your history with git reset and then give git push --force .

I'd rather do reset from gitk :

Soyoucanmakeresettoanypointinyourhistory.Topropagatethis,youmustdotheforcepush,whereyouforcearemotebranchupgrade.Occasionally,whenthegarbagecollectorisGitLabcomes,youroldcommitsshouldreallybedeleted.

  

NOTE:Ifsomeonemadetheforkofyourprojectbeforeyouresetthesevalues,thenyouarequitecapableofthesecommits.Soifyouhavesensitiveinformation,actassoonaspossible.

Ifyoujustwanttodeleteasinglecommitfromthelist,youcangettheothercommitsaftergitresetbydoinggitcherry-pick.

Inmycase,ifIwantedtoremovecommitfrom" Tab where it is due ", I should still do 4 cherry-picks:

git cherry-pick 11de53691964
git cherry-pick f119d69fe118
git cherry-pick f119d69fe118
git cherry-pick 9065a4213bd5

I already had to use this strategy to erase data that went wrong for GitHub, fortunately I did not notice any reading on the project before the adjustment. Under other circumstances, I've already had to undo merge requests in GitLab. Several times.

Doing revert was not suitable for me most of the time, because afterwards it causes confusion in the history with the old code (if it should actually enter). The revert , to me, matched when the old code needs to be completely undone without further damage and it was already too far-fetched to simply be deleted via% force_power .

A o situation where I successfully used git reset was commit of merge , then create a new < in> merge request with revert of revert . This served to remove a slightly defective code that came in and also served as the basis for writing revision comments in the code.

If you do not have access to the command line or simply abort it, you have the option via Web-GUI.

I'll get the following example: I have a branch revert with the following commits:

  • A (2fc99739)
  • B (5a0015bc)
  • C (75092a6b)
  • I want to rewrite as follows:

  • A (2fc99739)
  • C (???)
  • Removing B from history.

    In my repository, I have already created a branch called master for any catastrophes.

    First, we must create a new branch in commit A:

    So,let'scitethedesiredcommitoftheoldbranch(fail-safeincase):

    Afterthat,weselectthedesiredcommitsforcherry-pickmaster.Iopenedinanothertab,Irecommendtoopenallthedesirablecherry-pickcommitinothertabs(chronologicalorder)andselecttheoption75092a6bandtargetcherry-pick:

    Well,nowwehaveabranchwiththecorrecthistory:salvador-patria.Wejustneedtodeletethesalvador-patriapreviousandreplaceitwiththehistoryofmaster.

    Forthis,weneedtoremovethedefaultofsalvador-patriafirst(Ididthisbyassigningtoanyotherbranch):

    So now, just create a new branch from master called salvador-patria and set it back to default. These two processes have been shown previously, so you do not have to make new gifs.

        
    23.01.2018 / 12:29
    5

    Try to reverse your commit in gitlab:

    References:

  • Gitlab Docs
  • If this is not what you are looking for, you can take a look at this documentation at Gitlab - Rollback Commits

        
    23.01.2018 / 10:55