Last active
December 12, 2024 13:10
-
-
Save tdd/470582 to your computer and use it in GitHub Desktop.
Nice, useful global Git configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in your ~/.gitconfig or ~/.config/git/config | |
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName> | |
[user] | |
name = Your Full Name | |
email = your@email.tld | |
[color] | |
# Enable colors in color-supporting terminals | |
ui = auto | |
[alias] | |
# List available aliases | |
aliases = !git config --get-regexp alias | sed -re 's/alias\\.(\\S*)\\s(.*)$/\\1 = \\2/g' | |
# Command shortcuts | |
ci = commit | |
co = checkout | |
st = status | |
# Display tree-like log, because default log is a pain… | |
lg = log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset' | |
# Useful when you have to update your last commit | |
# with staged files without editing the commit message. | |
oops = commit --amend --no-edit | |
# Ensure that force-pushing won't lose someone else's work (only mine). | |
push-with-lease = push --force-with-lease | |
# Rebase won’t trigger hooks on each "replayed" commit. | |
# This is an ugly hack that will replay each commit during rebase with the | |
# standard `commit` command which will trigger hooks. | |
rebase-with-hooks = rebase -x 'git reset --soft HEAD~1 && git commit -C HEAD@{1}' | |
# List local commits that were not pushed to remote repository | |
review-local = "!git lg @{push}.." | |
# Edit last commit message | |
reword = commit --amend | |
# Undo last commit but keep changed files in stage | |
uncommit = reset --soft HEAD~1 | |
# Remove file(s) from Git but not from disk | |
untrack = rm --cache -- | |
[core] | |
# Don't paginate output by default | |
pager = cat | |
# Global ignore file (not shared) | |
excludesfile = ~/.gitignore_global | |
# Global shared hooks directory | |
# hooksPath = ~/.githooks | |
# | |
# Out of luck: on Windows w/o msysGit? You may have Notepad++… | |
# editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin | |
# | |
# If you want to use Sublime Text 2's subl wrapper: | |
# editor = subl -w | |
# | |
# Sublime Text 3 on Windows: | |
# editor = 'c:/Program Files/Sublime Text 3/subl.exe' -w | |
# | |
# VSCode | |
editor = code --wait | |
# Don't consider trailing space change as a cause for merge conflicts | |
whitespace = -trailing-space | |
[diff] | |
# Use better, descriptive initials (c, i, w) instead of a/b. | |
mnemonicPrefix = true | |
# Show renames/moves as such | |
renames = true | |
# When using --word-diff, assume --word-diff-regex=. | |
wordRegex = . | |
# Display submodule-related information (commit listings) | |
submodule = log | |
# Use VSCode as default diff tool when running `git diff-tool` | |
tool = vscode | |
[difftool "vscode"] | |
cmd = code --wait --diff $LOCAL $REMOTE | |
[fetch] | |
# Auto-fetch submodule changes (sadly, won't auto-update) | |
recurseSubmodules = on-demand | |
[grep] | |
break = true | |
heading = true | |
lineNumber = true | |
# Consider most regexes to be ERE | |
extendedRegexp = true | |
[log] | |
# Use abbrev SHAs whenever possible/relevant instead of full 40 chars | |
abbrevCommit = true | |
# Automatically --follow when given a single path | |
follow = true | |
# Disable decorate for reflog | |
# (because there is no dedicated `reflog` section available) | |
decorate = false | |
[merge] | |
# Display common-ancestor blocks in conflict hunks | |
# conflictStyle = diff3 | |
# Disable fast-forward merges as default merge strategy. | |
# Force explicit call of `git merge --ff …`. | |
ff = false | |
# Custom/dedicated merge drive for npm lock files (`package-lock.json`). | |
# Also works with Yarn. | |
# Use Git attributes to set targeted files (located at `~/.config/git/attributes`` | |
# when installed with npm). | |
# See https://www.npmjs.com/package/npm-merge-driver | |
# [merge "npm-merge-driver"] | |
# name = automatically merge npm lockfiles | |
# driver = npx npm-merge-driver merge %A %O %B %P | |
[mergetool] | |
# Clean up backup files created by merge tools on tool exit | |
keepBackup = false | |
# Clean up temp files created by merge tools on tool exit | |
keepTemporaries = false | |
# Put the temp files in a dedicated dir anyway | |
writeToTemp = true | |
# Auto-accept file prompts when launching merge tools | |
prompt = false | |
# [page] | |
# Use custom pager to get an better log on terminal. | |
# As this is an external tool it has to be installed. | |
# See https://github.com/so-fancy/diff-so-fancy | |
# show = diff-so-fancy | less --tabs=4 -RFX | |
[pull] | |
# This is GREAT… when you know what you're doing and are careful | |
# not to pull --no-rebase over a local line containing a true merge. | |
# rebase = true | |
# This option, which does away with the one gotcha of | |
# auto-rebasing on pulls, is only available from 1.8.5 onwards. | |
# rebase = preserve | |
# WARNING! This option, which is the latest variation, is only | |
# available from 2.18 onwards. | |
rebase = merges | |
[push] | |
# Default push should only push the current branch to its push target, regardless of its remote name | |
default = upstream | |
# When pushing, also push tags whose commit-ishs are now reachable upstream | |
followTags = true | |
# [rebase] | |
# Rebase advanced usage. | |
# Automagically reorder and prefix your commands while doing an interactive | |
# rebase. This has to be used with `--fixup` and/or `--squash` options for | |
# `git commit`. | |
# autoSquash = true | |
# Automatically stash current WD and stage when running rebase | |
# then you won't have to manually `git stash push` and `git stash pop` | |
# after and before your rebase. | |
# autoStash = true | |
# [rerere] | |
# If, like me, you like rerere, uncomment these | |
# autoupdate = true | |
# enabled = true | |
[status] | |
# Display submodule rev change summaries in status | |
submoduleSummary = true | |
# Recursively traverse untracked directories to display all contents | |
showUntrackedFiles = all | |
[color "branch"] | |
# Blue on black is hard to read in git branch -vv: use cyan instead | |
upstream = cyan | |
[tag] | |
# Sort tags as version numbers whenever applicable, so 1.10.2 is AFTER 1.2.0. | |
sort = version:refname | |
[versionsort] | |
prereleaseSuffix = -pre | |
prereleaseSuffix = .pre | |
prereleaseSuffix = -beta | |
prereleaseSuffix = .beta | |
prereleaseSuffix = -rc | |
prereleaseSuffix = .rc |
Dernière mise à jour à l'instant, suite aux suggestions de @mbrehin
@bgondy on utilise diff-so-fancy même si ça n’est pas retranscrit ici (on ne veut pas forcer la main et imposer un outil externe aux gens qui souhaitent récupérer cette conf).
En pratique notre conf contient ça : pager = diff-so-fancy | less --tabs=4 -RFX
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Heeeeu en fait pull.rebase ne change rien au fonctionnement du fetch, c'est après que ça change (rebase au lieu de merge). Du coup si tu ne vois rien avant la partie rebase, c'est qu'en fait tu étais, sur ton essai, à jour côté fetch.