lundi 16 août 2021

How to Delete commits from a branch in Git - Git the Final Ultimate

In Git you don't have the straight command like to direct "delete a commit" but you can do like by deleting the concernig part of the local branch the commits are on.

Using Fork (wonderfull tool around git)  you should do two or tree things (or in Git with the commands you will find) :

  • first you "Reset HEAD to here" you place yourself where you want to be in remote branch after you will suppress the commits you don't want anymore,.then you choose "Hard Discard all local changes" :
Git delete commit with Fork
Git delete commit with Fork
  • secondly you can "delete the local branch" with the commits you don't want anymore.
  • Then you can "push to origin" where you are, you must choose "force push"...

This is not really simple, you have to understand the "Git" way of doing things, but at the end this is the most powerful tool ;-)

Il y a un dessin important et récapitulatif des commandes Git que l'on doit à GitLab :

Git Data Transport Commands

Concernant Git et la difficulté qu'il peut y avoir à prendre en main cet outil puissant de gestion de configuration logicielle. Je voulais noter ici un article d'un intérêt tout particulier. Il met en garde concernant la commande Pull de Git en utilisant cet angle pour aborder un cas d'utilisation de Git en groupe dans un groupe de développeurs :

GitAddict - Attention au pull !

Remenber two other things, fisrt, Fork is the most wonderfull tool to work with Git :

The wonderfull tool to work with Git
The wonderfull tool to work with Git

second, don't forget to go to the beach.

Pour moi, c'est The Git Ultimate, vous avez le magnifique dessin de l'ensemble des commandes Git, d'où elles partent, et où elles arrivent. C'est la base de Git ! 

Vous avez cet article sur la limite de l'utilisation du pull ou de la nécessité de le configurer en Git + fetch ou Git + rebase important pour ne pas perdre le fil de votre développement quand vous êtes plusieurs devs, donc si vous avez besoin de formation vous savez où vous adresser.

Et vous avez ce fantastique outil Fork de Dan et Tanya Pristupov bravo à eux. Et quand je dis fantastique c'est vraiment très au delà de tous les autres outils d'utilisation de Git. Pour moi, c'est mon meilleur collègue préféré qui me l'a fait adopter avec une démonstration de quelques minutes et une fois lancé sur Fork, je n'imagine plus d'utiliser autre chose.

Voilà c'était l'ultimate car avec les éléments que je viens de vous livrer, j'espère que ne n'aurais plus aucun autre article à consacrer à Git et que je vais pouvoir passer à GitHub. 

Je vais aller faire de la doc avec GitHub Page & Jekyll.

Have fun!