Skip to content

Instantly share code, notes, and snippets.

@jlandure
Last active February 21, 2024 12:39
Show Gist options
  • Save jlandure/c887de9f2508d5ad850c215399409696 to your computer and use it in GitHub Desktop.
Save jlandure/c887de9f2508d5ad850c215399409696 to your computer and use it in GitHub Desktop.
git global options + tips
IL that git push -u origin my-new-branch is no more needed with push.autoSetupRemote :
git config --global --add --bool push.autoSetupRemote true
git config --global --add --bool pull.rebase true
git config --global --add --bool rebase.autoStash true
git config --global --add --bool fetch.prune true
# git undo
git config --global alias.undo '!f() { \
git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; \
}; f' => http://megakemp.com/2016/08/25/git-undo/
# affiche les fichiers dans l'ordre de leur fréquence d'apparition dans les commits
git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head
# ca genere pas les .orig
git config --global mergetool.keepBackup false
#afficher la branche
git rev-parse --abbrev-ref HEAD
#afficher le SHA
git rev-parse --short HEAD
#afficher le repo distant
git remote -v | head -1 | awk '{print $2}'
#afficher la dernière version d'un répertoire
git rev-list -1 HEAD -- "front"
#afficher la dernière version
git log -n 1 --pretty=format:"%H"
alias git-clean-b="git fetch -p && for branch in `git branch -vv --no-color | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done"
Placer le ou les workspaces ici
+git archive --format=zip -o tps+corrections.zip HEAD .
Sparse checkout to get only one file (config for example)
git clone --no-checkout --single-branch --no-tags --depth 1 git@localhost:foo/bar
git config core.sparseCheckout true
echo "path/to/your/file" > .git/info/sparse-checkout
git checkout master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment