Have you ever used git config?
If you have ever used git, I think you have also used git config
, but probably only once or twice to set your name and email address. But what else can you do?
a dog > log#
As you probably know, git log
shows a lot of information. You usually don’t want that. Instead, you’d like to see a nice graph with only commit names and hashes. To do that without much typing, I recommend setting
git config --global alias.adog "log --all --decorate --oneline --graph"
and using git adog
instead.
branch shouldn’t be like less#
In git 2.16 a change in the branch
command was made (which I consider quite stupid). If you run git branch
, it behaves like less
(at least on Linux), so that if you want to go back to the command prompt by pressing q, you don’t see the branches anymore. Fortunately, it’s possible to revert that change by setting
git config --global pager.branch false
last but not least — or is it?#
Sorting branches by their name is well… a choice. Typically, when I use git branch
I’d like to see most recent ones first. We can override the default behavior by
git config --global branch.sort -committerdate
closing remarks#
Please, use git push --force-with-lease
instead of simple git push --force
. It will work in the same way if you simply used git commit --amend
a moment after the first commit, but rejects the change if someone else pushes to the branch in the meantime.
I don’t think there is an option to use --force-with-lease
by default, but you can always create an alias, like
git config --global alias.pushf "push --force-with-lease"
If you feel a bit unsatisfied after this short post and want to learn more, you can go and watch a talk by Scott Chacon at FOSDEM 2024. His talk isn’t heavily focused on config
, but it’s worth watching nonetheless.