24 March 2019

blog java

J'essaye d'éviter d'installer git pour windows avec son bash minimal, qui ne fait pas une installation très propre.

Création Clef ssh sur github

Tout d'abord, création de la clef sur github en copiant la clef publique interprétée, par exemple en la chargeant dasn puttyGen.

Ensuite, en utilisant pageant, chargement de la clef privée et saisie du mot de passe.

En utilisant putty pour se connecter avec
git@github.com

Option "Dont start a shell or other command at all" dans l'onglet ssh.

En regardant les logs dans eventLog :
2019-03-24 18:40:16 Connecting to 140.82.118.3 port 22
2019-03-24 18:40:16 We claim version: SSH-2.0-PuTTY_Release_0.68
2019-03-24 18:40:17 Server version: SSH-2.0-babeld-c6e8f0d0
2019-03-24 18:40:17 Using SSH protocol version 2
2019-03-24 18:40:17 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
2019-03-24 18:40:17 Server also has ssh-dss host key, but we don't know it
2019-03-24 18:40:17 Host key fingerprint is:
2019-03-24 18:40:17 ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
2019-03-24 18:40:17 Initialised AES-256 SDCTR client->server encryption
2019-03-24 18:40:17 Initialised HMAC-SHA-256 client->server MAC algorithm
2019-03-24 18:40:17 Initialised AES-256 SDCTR server->client encryption
2019-03-24 18:40:17 Initialised HMAC-SHA-256 server->client MAC algorithm
2019-03-24 18:40:17 Pageant is running. Requesting keys.
2019-03-24 18:40:17 Pageant has 1 SSH-2 keys
2019-03-24 18:40:17 Trying Pageant key #0
2019-03-24 18:40:17 Sending Pageant's response
2019-03-24 18:40:17 Access granted

La connection à l'air de fonctionner.

Installation d'un proxy dans eclipse pour fonctionner avec pageant

https://eclipseguru.github.io/eclipse-jsch-agent-proxy/

Les éléments installés :
Warning: You are installing software that contains unsigned content. The authenticity or validity of this software cannot be established. Do you want to continue with the installation?
C:\Users\hnl-bis.p2\pool\plugins\com.jcraft.jsch.agentproxy.eclipse.sshagent_1.0.0.201606231331.jar
C:\Users\hnl-bis.p2\pool\features\com.jcraft.jsch.agentproxy.eclipse.sshagent_1.0.0.201606231331

Dans eclipse, configuration ssh2. J'utilise ~.ssh par défaut (au lieu de ~/.ssh).

Ajout de la clef privée (et publique) dans le répertoire .ssh.

Configuration de git pour utiliser JSch.

Lors du push, la passphrase est demandée, et on peut continuer.

Problème de fichier trop grand

Repository git@github.com:CSTIS/canhelp.git

pre-receive hook declined
error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
error: Trace: 0bbe2b4aaddf39dddf7bdc4b3a53515a
error: See http://git.io/iEPt8g for more information.
error: File bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql is 248.94 MB; this exceeds GitHub's file size limit of 100.00 MB

Il faut donc retirer ce fichier de l'historique. (Pour des raisons de confidentialité).

Nettoyage du dépot

commit 054c76c49c0629fbe0960cfefedcbb4c7226ccf9
Author: sbodin sbodin@cst.fr
Date: Thu Feb 25 11:40:13 2016 +0100

> git log  bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql 
merge canhelp.sql


> du -sh .git
188M    .git
> du -s .git
192160  .git


> git filter-branch --tree-filter 'rm bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql' HEAD
Rewrite 6d972138ed93bf77512687a8074e5cbe6de38249 (1/1162) (0 seconds passed, remaining 0 predicted)    rm: impossible de supprimer 'bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql': Aucun fichier ou dossier de ce type
tree filter failed: rm bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql
> ls bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql
bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql

Il fallait ajouter les options -rf à rm :

> git filter-branch --tree-filter 'rm bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql' HEAD
Il y a 1162 fichier à réécrire

du -s .git
197016 .git

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch bdd_archives/canhelp2016_cannes2015_dev-2016-01-18-12h15.sql' --prune-empty --tag-name-filter cat -- --all

du -s .git
197832 .git

git gc --aggressive
Décompte des objets: 13380, fait.
Delta compression using up to 2 threads.
Compression des objets: 100% (13138/13138), fait.
Écriture des objets: 100% (13380/13380), fait.
Total 13380 (delta 9552), reused 2339 (delta 0)

Le dépot ainsi nettoyé peut être uploadé vers github.

Problème affichage des noms

Un grand nombre de commits sont mal affectés.

Si je cherche la liste des auteurs :

> git shortlog -e -s -n
   548  sbodin <sbodin@cst.fr>
   306  hnl-bis <hnl-bis@DESKTOP-7DKD13M>
   138  Hans-Nikolas Locher <hnlocher@cst.fr>
    95  ssalah <ssalah@e79222a6-4db9-11e1-9923-416be07c893d>
    31  Hans-Nikolas Locher (Laptop) <hnlocher@cst.fr>
    22  sbodin <sbodin@e79222a6-4db9-11e1-9923-416be07c893d>
    13  hnlocher <hnlocher@e79222a6-4db9-11e1-9923-416be07c893d>
     6  hnl-bis <hnl-bis@192.168.24.154>
     2  sbodin <sbodin@192.168.24.171>
     1  sbodin <sbodin@localhost>

On voit que la liste suivante est mal affectée :
* 306 hnl-bis hnl-bis@DESKTOP-7DKD13M
* 95 ssalah ssalah@e79222a6-4db9-11e1-9923-416be07c893d
* 22 sbodin sbodin@e79222a6-4db9-11e1-9923-416be07c893d
* 13 hnlocher hnlocher@e79222a6-4db9-11e1-9923-416be07c893d
* 6 hnl-bis hnl-bis@192.168.24.154
* 2 sbodin sbodin@192.168.24.171
* 1 sbodin sbodin@localhost

Saïd Salah said.salah@capgemini.com

https://help.github.com/en/articles/changing-author-info

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

Je transforme en :

#!/bin/sh

git filter-branch -f --env-filter '
# Sebastien
if [ "$GIT_COMMITTER_EMAIL" = "sbodin@localhost" -o "$GIT_COMMITTER_EMAIL" = "sbodin@192.168.24.171" -o "$GIT_COMMITTER_EMAIL" = "sbodin@e79222a6-4db9-11e1-9923-416be07c893d" ]
then
    export GIT_COMMITTER_NAME="Sebastien Bodin"
    export GIT_COMMITTER_EMAIL="sbodin@cst.fr"
fi
if [ "$GIT_AUTHOR_EMAIL" = "sbodin@localhost" -o "$GIT_AUTHOR_EMAIL" = "sbodin@192.168.24.171" -o "$GIT_AUTHOR_EMAIL" = "sbodin@e79222a6-4db9-11e1-9923-416be07c893d" ]
then
    export GIT_AUTHOR_NAME="Sebastien Bodin"
    export GIT_AUTHOR_EMAIL="sbodin@cst.fr"
fi
# Saïd
if [ "$GIT_COMMITTER_EMAIL" = "ssalah@e79222a6-4db9-11e1-9923-416be07c893d" ]
then
    export GIT_COMMITTER_NAME="Saïd Salah"
    export GIT_COMMITTER_EMAIL="said.salah@capgemini.com"
fi
if [ "$GIT_AUTHOR_EMAIL" = "ssalah@e79222a6-4db9-11e1-9923-416be07c893d" ]
then
    export GIT_AUTHOR_NAME="Saïd Salah"
    export GIT_AUTHOR_EMAIL="said.salah@capgemini.com"
fi

# Hans-Nikolas
if [ "$GIT_COMMITTER_EMAIL" = "hnl-bis@192.168.24.154" -o "$GIT_COMMITTER_EMAIL" = "hnlocher@e79222a6-4db9-11e1-9923-416be07c893d" -o "$GIT_COMMITTER_EMAIL" = "hnl-bis@DESKTOP-7DKD13M" ]
then
    export GIT_COMMITTER_NAME="Hans-Nikolas Locher"
    export GIT_COMMITTER_EMAIL="hnlocher@cst.fr"
fi
if [ "$GIT_AUTHOR_EMAIL" = "hnl-bis@192.168.24.154" -o "$GIT_AUTHOR_EMAIL" = "hnlocher@e79222a6-4db9-11e1-9923-416be07c893d" -o "$GIT_AUTHOR_EMAIL" = "hnl-bis@DESKTOP-7DKD13M" ]
then
    export GIT_AUTHOR_NAME="Hans-Nikolas Locher"
    export GIT_AUTHOR_EMAIL="hnlocher@cst.fr"
fi


' --tag-name-filter cat -- --branches --tags

Résultat des courses :

> git shortlog -e -s -n
   548  sbodin <sbodin@cst.fr>
   463  Hans-Nikolas Locher <hnlocher@cst.fr>
    95  Saïd Salah <said.salah@capgemini.com>
    31  Hans-Nikolas Locher (Laptop) <hnlocher@cst.fr>
    25  Sebastien Bodin <sbodin@cst.fr>

On recommence

Certaines branches n'avaient pas étés poussées en amont. Il faut donc tout recommencer.

Un peu de ménage dans les branches en contradictions.

Récupération des branches en local.

git pull asgard

Récupération des branches remote en local

for i in $(git branch -r|grep -v -- '->' ); do git checkout -b $(basename $i) $i; done