Git Commands - andretti1977/linux-commands GitHub Wiki

GIT

https://git-scm.com/docs/git-credential-cache
https://stackoverflow.com/questions/14643308/git-force-user-and-password-prompt
https://stackoverflow.com/questions/13198143/how-do-i-disable-gits-credential-helper-for-a-single-repository/13203623#13203623

git reset origin to commit

https://www.christianengvall.se/git-reset-origin-master-to-commit/

set credential cache for 20 seconds

This command let a credential cache live for 20 seconds. If git commands are issued within the timeout, then a new 20 seconds timeout is issued. The meaning is that any git command "refreshes" the timeouts.

git config --global credential.helper 'cache --timeout=20'

git reset --hard origin/master (sorta di force override)
git remote prune origin --dry-run (indica quali eliminerebbe dei rami locali che non hanno più un remote, ma se il ramo era solo locale non lo elimina

superare unrelated histories

git branch --set-upstream-to=origin/master master (setta master to master) git pull --allow-unrelated-histories

git push force

git push --force

Risorsa interessante per creare un set di file a partire da un commit:

https://tosbourn.com/using-git-to-create-an-archive-of-changed-files/

differenza tra rami

fornisce nomi dei file modificati in differenza con percorsi relativi
git diff --name-only feature/remove-nonce-check master

init e aggiunta remoto

git init
git add --all
git commit -am "the message"
git remote add origin url.git
git push -u origin master

cambio dei remote

git remote set-url origin [email protected]:company/app.git

mantenere sessioni multiple verso stesso host (una chiave per determinato account)

Editare il file ~/.ssh/config Creare una entry specifica per:

Host bitbucket.org-servizio
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/id_rsa_servizio

Poi clonare (o settare l'origin) come

git remote set-url origin [email protected]:company/app.git

In pratica nel config si è creato un alias all'hostname reale (bitbucket.org-servizio, ma potevo scrivere anche pippo) e questo viene usato per il clone o il set del remote

testare la chiave ssh usata (git, ma ssh anche)

ssh -v bitbucket.org-arstrends

Ti mostra cosa succede e se può loggarsi