Popular Git config options
jvns.ca
jvns.ca
[alias]
lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all -n 15
Which I took from this Stack Overflow post:
https://stackoverflow.com/questions/1057564/pretty-git-branc... -—graph -—oneline -—colorrebase.autosquash combined with an alias I have (called 'fixup') to make that commit and then do the rebase is probably my top one by an absolute long shot, at least in terms of frequency of use. pull.rebase is important to me, but I fixup so frequently, I really don't know how people get by without it.
(Well, I do, generally they create a snaking history by merging master or whatever into their own branch repeatedly, swapping the parents, and make lots of new commits to fix things in the old ones. But I don't know how you can put up with doing that to yourself, is I suppose the long version of what I mean.)
Oh - semi-missed - insteadOf is more useful than implied: I have 'gh:' mapped to the full thing, so I just `git remote add somefork gh:someforker/the-project`, for example.
Some other minor ones: advice.statusHints=false; include.path (if you need it you need it - I use it to set my signing key according to which Yubikey is plugged in, plugging can write the whole file because it's all that's in there, no parsing required); remote "origin".fetch set to get PRs; oh and interactive.singleKey = true if that was missed - not a minor one at all! Makes staging changes so much faster and easier. Obviously not as fast as `add .` or `commit -a`, but don't do that.
Host github
Hostname github.com
User git
Then you can do a "git clone github:microsoft/windows" and you're good to go.If you've evolved an SSO solution from brownfield, or just merged with another company you can easily end up in a spot where you have 2 user names across the systems, and that's before you get into doing things like pushing bug fixes to Github straight from your work machine.
Make yourself an .ssh/config file. Set your user, and your ssh key for where it matters (I don't use the same key for ssh to servers and for talking to github or bitbucket)
Another good setting for your ssh config if you use different keys for different servers is to require passing a key for all hosts rather than it trying each of your keys to see which one works:
Host * IdentitiesOnly yes
So I spend half an hour to learn about git shell commands in aliases (had to learn the hardware that arguments require functions) and came up with the following.
fixup = "!f() { git commit --fixup ${1} && GIT_SEQUENCE_EDITOR=true git rebase --autosquash --interactive --rebase-merges \"${1}~1\"; }; f"
from https://gitlab.com/olliver/dotfiles/-/blob/master/.config/gi...
Hope this helps anybody else :)
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
dft = difftool
[tag]
sort = version:refname
[tar "tar.xz"]
command = xz -c
[tar "tar.zst"]
command = zstd -T0 -c
[log]
date = iso-local
[pull]
ff = only
[diff]
tool = difftastic
[difftool]
prompt = false
[difftool "difftastic"]
cmd = difft "$LOCAL" "$REMOTE"
[pager]
difftool = true
[safe]
directory = *
[advice]
detachedHead = false
[init]
defaultBranch = masterPretty good config though. Personally, I use diff configs depending on oss vs personal vs work. So I combine mine with “[includeIf gitdir:~/oss…]” …
Some companies like G have some weird requirements.
> Personally, I use diff configs depending on oss vs personal vs work. So I combine mine with “[includeIf gitdir:~/oss…]” …
I'd stuff such things into the local repos' .git/config files instead of the global. It's rare that I do it, but sometimes I do work with projects with differing conventions.
Why not 'canon'?
[alias]
gr = grep -I
ch = cherry-pick
ls = ls-files
tip = log -1 HEAD
zip = archive -o latest.zip HEAD
fix = commit --fixupNow the first time I commit in a new repo, it errors out with "Author identity unknown" and I punch in "git config user.email ADDR" for the email I want to use and re-run the commit.
I’ve tried conditionally setting email based on the remote [1], but for some reason I did not manage to make it work. I didn’t try too hard, and I might try again with more patience.
[1] https://www.brantonboehm.com/code/conditional-git-config/
[ghq] # https://github.com/x-motemen/ghq#configuration
root = ~/dev
Sometimes, from my personal machine, I need to check something work-related ; then on my personal machine, I checkout in `~/dev/myorganization/`.
Inversely, it happens sometimes that at work I need something I wrote for myself ; then on my work machine, I checkout in `~/dev/myusername/`.This allows me to use `gitdir:` rules that handle anything `~/dev`, and I have fallbacks for everything else (who never checkouts in `tmp`?).
#
# Superman vs Clark Kent
#
# Debug Includes with: git config --list --show-origin
# the default identity, for checkouts outside of `~/dev`
[include]
path = ~/.config/git/gitconfig-default
# on my work machine, this defines Clark Kent ; on my personal machine, this defines Superman (or is it the reverse?)
# this one is not commited in my dotfiles
[include]
path = ~/.config/git/gitconfig-local
# work-related repos on personal machine
[includeIf "gitdir:/home/myusername/dev/myorganization/"]
path = ~/.config/git/gitconfig-myorganization
[includeIf "gitdir:/home/myusername/dev/gitlab.com/myorganization/"]
path = ~/.config/git/gitconfig-myorganization
# personal repos on my work machine
[includeIf "gitdir:/home/myusername/dev/myusername/"]
path = ~/.config/git/gitconfig-myusername
[includeIf "gitdir:/home/myusername/dev/gitlab.com/myusername-namespace/"]
path = ~/.config/git/gitconfig-myusername
This works nicely since years^W `includeIf` was a thing.However, there are situations at work where I'm on a server where I didn't created `~/.config/git/gitconfig-local` (which is a manual step I always forget) and any commit from `/usr/local/src/something/` will end up configured with Superman identity.
I found out about `hasconfig:` some time ago, and took note of it for when the option would hit `git` from Debian Stable ; your comment comes the day after I accidentaly commited as Superman on some work repo checked outside of `~/dev/`. Time to add more rules!
I just use different accounts depending on the context, usually by either SSH or by starting a Docker container with all the environment already configured.
At least for me, using different identities[1] when I want to use different identities[2], seems less brittle and less likely for my future self to accidentally forget to do something (e.g. change a config when I reinstall an OS).
[1]: OS user, directly (SSH) or indirectly (container).
[2]: Email address, username, etc.
[core]
autocrlf = input
safecrlf = true
It prevents commiting CRLF files and forces you to convert those to LF before commit (you can still override it with gitattributes if necessary). I hate CRLF so much that I spent lots of time digging out this combination of configuration values. # Enforce `lf` for text files (even on Windows)
* text=auto eol=lf
I'll try your config too.My current position is that anywhere you can choose between CRLF and LF (git, editor, program output), it should always be LF regardless of the platform. Simple LF just works on Windows, and removing this variation point simplifies so much of code. For example, you can check reproducible outputs or hashing with a single reference value.
[alias]
checkout-default = "!git checkout $(git rev-parse --abbrev-ref origin/HEAD | sed 's@^origin/@@')"
[1] https://github.com/dandavison/deltaChange the comment character. This is useful when you want to include a hash in your commit message (e.g. for automatically linking to JIRA tickets).
[core]
commentChar = ";"
When starting a new branch/ticket you can create an empty commit where you write a detailed subject and description. [alias]
newtask = commit --allow-empty
Create a zip archive of the current files. [alias]
zip = archive -o latest.zip HEAD
Switch between the last two active branches with: git checkout -
Use short log lines: [format]
pretty = format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s
Some delta tweaks: [delta]
features = decorations # line numbers
navigate = true # use n and N to move between diff sections
And finally: [alias]
praise = blame git config --global --get-regexp . | sort -u
A hack I like that makes diffing possibly minified or formatting-mangled source files easier: diff.css.textconv css-beautify
(Unminifies and unifies the formatting of css files before diffing them, might need to have the *.css type set in your .gitattributes though) core.editor nvim
(Use neovim as the editor for commit messages and other things) [alias]
ls-alias = config --global --includes --get-regexp 'alias\..*'[alias]
alias = "!git config --get-regexp ^alias. | sed 's/^alias.//'"I've seen so many new engineers struggle for years not being able to figure out conflicts until someone tells them about diff3. The default here has likely wasted millions of dollars of productivity.
If that’s too much for you, vscode renders the conflict similar to the raw representation but with pretty “accept mine” buttons next to it.
The default behaviour of pull makes complete sense in the distributed system. It goes wrong when developers are also pushing to remotes and doing feature branches and the like. I love forges like GitHub, but I understood git first. Developers nowadays are using a decentralised version control tool to do centralised version control. No wonder it goes wrong.
Especially since places like GitHub are making main the default unwittingly
This typifies why the US still runs on imperial units, not metric. Don't crush that dwarf, hand me the 16mm pliers.
But you know, some people around me strongly dislike calling it "master". I don't have strong feelings about it. They do. Their desire to call it something else is far greater than any desire I might have to not to. Switching to "main" cost me nothing, saves a couple keystrokes, and makes other people happy. Fine, let's do it.
If you want to use "master" on your own internal projects, go for it. No one's stopping you. I definitely wouldn't use it on a shared project because the potential cost of irritating someone isn't worth it. And because I don't want to have one set of muscle memory for my own projects and another for shared projects, I just use "main" everywhere.
As a matter of policy, I refuse to be swayed by the opinions of busybodies as to what is or isn't offensive. I will continue to use blacklists, for example, but am happy to retire the master/slave pairing: it's not a great metaphor to begin with, and a reasonable person can see where those of recent descent from the enslaved might take exception to it.
There's nothing at all wrong with having a master branch, either, the metaphor is entirely anodyne and no honest person takes umbrage at it. But that whole absurd episode got me thinking about the nomenclature, I had been working with Fossil on a hobby project shortly before, and figured that if there's another word which I prefer, I may as well take the opportunity to switch.
[0]: https://en.wikipedia.org/wiki/Branching_(version_control)
>As a matter of policy, I refuse to be swayed by the opinions of busybodies as to what is or isn't offensive.
Well, you have said multiple ways that you have been swayed. I agree with you about all of this whining and word-policing coming from people who have dubious intentions. Nobody sane is offended by these terms. It's just a way for "victims" to seek clout and bully everyone else.
Fossil is cool but alas it will never be mainstream. It does have some nice features, but there are technical downsides such as storing files in a single binary sqlite database (which is a benefit for small projects, but a bad solution for large projects). If nothing else, backing up Fossil repos will take an ever-increasing amount of space compared to an equivalent git repo, as git repos can be backed up incrementally.
I tried to address this in my first post, but don't mind elaborating.
I think trunk is the better term. I felt that way before all the absurdity surrounding master branches, but not so strongly that it had even occurred to me to set it as a git default and migrate my projects to use it. The sick power games of moral busybodies were causal in the sense that it started "a conversation" (ugh) about branch naming, with the result that I now use trunk on my own projects.
If I had stuck with master despite preferring trunk, just to show them what's what, that is also being swayed by the opinions of busybodies, just in the other direction. The busybodies of the world also want me to wear a seatbelt, after all. We have a confluence of wants there.
Similar deal with referring to various software components as slaves. I find that distasteful. I didn't need the language police to raise that topic to have that opinion. It's not even a good metaphor! Should I insist on using it just because the people who throw a hissyfit about blacklists share my dislike for that terminology? That is also being swayed by their opinions.
Anyway:
> Fossil is cool but alas it will never be mainstream.
Indeed, a nice bit of software, pleasure to work with. Rather too narrowly tuned to D. Richard Hipp's needs to be mainstream. I proposed on the Fossil mailiing list (right before they shipped a built-in forum) to separate the core features into a libfossil so people could use it as a component of other systems, but for a few reasons (which I found persuasive fwiw) they don't plan to do so.
I would still like to see pijul displace git, but as the years pass the odds of that steadily decrease. Ah well.
>If I had stuck with master despite preferring trunk, just to show them what's what, that is also being swayed by the opinions of busybodies, just in the other direction.
This is pretty subtle. I would discourage the use of unconventional names for your branches, just because it creates more confusion. Were you influenced if you kept things the same because you didn't like the idea of change or the messengers asking you to do it? I guess technically, you could be psychologically influenced and not make any actual change. But to other people, your state of mind is not the object of interest, especially if it produces no outcome. They only care if you made the change or not. Thus, if you were not persuaded to change anything, then you weren't influenced.
>Similar deal with referring to various software components as slaves. [...] It's not even a good metaphor!
It is a good metaphor in fact. Slaves are workers that take assignments from their owner (and not others), among other things. At least in some contexts, you could list several things that a master/supervisor does that directly mirror how human slaves operate. If it was a bad metaphor, semantically speaking, then people would be legitimately confused when it was used. Nobody ever said they found it confusing before the language police rolled up.
I will admit that having "slave" stuff is perhaps in poor taste. You could make a far better case for that than the use of the word "master".
The trouble with all of this is, language policing is not primarily about the words. We won't be rid of the language police after making the suggested changes. They want power. Language and preferences are coming full circle to where "colored people" is bad but "person of color" is good, segregation and discrimination are ok again (especially to the exclusion of whites), etc. Martin Luther King would be appalled at the modern left.
trunk has been the conventional name for the trunk branch of version control systems longer than anything else. "Child branches are branches that have a parent; a branch without a parent is referred to as the trunk or the mainline." https://en.wikipedia.org/wiki/Branching_(version_control)
git provides a way to determine which branch is the trunk, which it calls the default. Software which tries to guess at this is already broken, and for software which does it correctly, the name itself is completely irrelevant.
> It is a good metaphor in fact.
I disagree. In databases, for one example, what was conventionally called the slave is a replica. Is a slave a replica of his master? No, that's absurd. There are contexts in which one part of the system controls things, and the other is purely responsive or helpful, and I will grant you that in those cases, master/slave is a coherent metaphor, but the word "servant" can be used without loss of expressive power, and I see adequate reason to prefer that usage. In most cases where master/slave is used, master/replica or primary/secondary are in fact clearer than master/servant.
> The trouble with all of this is, language policing is not primarily about the words. We won't be rid of the language police after making the suggested changes.
Well yes, of course, we agree vigorously on this. I ask you: how does one grant these control freaks the least possible power? Clearly bowing to their every whim is a losing approach: if someone wants to pick a fight with me about the use of the term "blacklist", very well, they'll get their fight, because I won't stop.
But making a point of using terminology just because they don't like it is granting them a certain power as well, through the very act of rebellion. I genuinely think trunk is the best term for a trunk branch, so I use it. If you think master is better, I will disagree, and say no, trunk is better! But I won't call it offensive, that's just silly.
I've been wondering about this myself. It seems to be part of a communist-adjacent power grab. The objective is to install useful idiots in all the right places so certain people can use fear to keep others in line, and ultimately advance more ambitious agendas of oppression. I'm still doing research on this subject. I just found a blog today at https://newdiscourses.com that seems dedicated to fighting this fight. It's relatively high-IQ stuff.
Anyway I agree that "trunk" is a better name than "master" or "main" for a new version control system, at least if it uses "branch" terminology. But git has been established for many years and we are only talking about an inconvenient change because of activists. Simply ignoring the activists and continuing as usual is not "granting them power"... Unless you are making a change away from something else over to "master" naming lol.
Unfortunately, there is no consistent meaning for what the master/main branch actually is out in the wild. It could be the stable branch or it could be the development branch, or it could be an old ref retained out of fear by someone who decided to jump on the renaming bandwagon. But I think for developer-centric projects, master is the stable dev branch. For user-centric project, it is often the last stable release branch. Both of these make sense.
Why would that be? Pijul is getting better, simpler and faster all the time.
It really isn’t worth it. I can agree with using ‘main’ when making new repos but trying to shoehorn ‘main’ into existing stuff is a giant pain for little to no gain.
The general conclusion is that relatively few FOSS tools collect usage information the way commercial software now does. Interesting opportunity to potentially improve things.
...you mean by changing commercial software to collect telemetry more like FOSS tools do, i.e. usually not at all, right?
Telemetry and usage information is not bad in and of itself. It's a perfectly valid tool that can be used to find rough edges on your product and improve them. It's a great way to determine the most commonly used operations. Every developer who has worked on products used by real people inevitably discovers that their users approach their software in ways completely different than intended. Some of these unintended ways represent valid use cases the developer or product owner never anticipated. If you discover these things, you can improve the product by making that operation a first class operation instead of a weird workaround. If you're not collecting metrics, you're only listening to the most noisy parts of your user base who are by definition a small minority.
I don't understand the popularity of meld. I always felt that meld it's pretty inferior to kdiff3. And I give a few try to it...
https://www.perforce.com/products/helix-core-apps/merge-diff...
[alias]
fb = !fzf_prompt.sh # prompts the user with an fzf prompt to fuzzy search for branches
cheese-touch = "log -n 1 --format=format:'%an' --" # displays who edited a file last
destroy = "!git reset HEAD~1 && git add --all . && git reset --hard" # destroys top commit
sc = "commit --amend --no-edit" # *jackie chan's uncle voice* one more thing!
pushf = "push --force-with-lease" # *lego batman voice* first try!
all = "!git add --all . && git status" # I forget that this doesn't exist on everyone's computer.
cp = "cherry-pick" # this one feels obvious but that saves me so many letters
---fzf_prompt.sh---
#!/usr/bin/env bash
branch=$(git for-each-ref --shell --format='%(refname)' refs | cut -d/ -f3- | grep -Eo "[^']+" | fzf-tmux -d 15);
if [[ ! -z "$branch" ]]; then
if [[ $branch == origin/* ]]; then
branch=$(echo $branch | cut -d/ -f2-)
fi
git checkout "$branch"
fiSo cheese touch is the last person to touch that file. Every time someone touches the file the cheese touch transfers. And if that file broke the build or something you can find out who has the cheese touch on that file and t̶r̶e̶a̶t̶ ̶t̶h̶e̶m̶ ̶l̶i̶k̶e̶ ̶a̶n̶ ̶o̶u̶t̶c̶a̶s̶t̶ ask them nicely if they know what's happening.
editor = "nano -t"
This nano option is aka --saveonexitThings accomplished:
- avoids using an overpowered modal editor that requires several keystrokes just to save and quit when done writing my couple of sentence commit message
- avoid even having to tell it I want to save. Of course I want to save. ^x - all done
(In the unlikely event you decide you want to abort the commit, just hit ^k a few times to kill the text and then ^x)
(Edit: Updated to the default exit keybinding which is ^x)
EDIT: And of course there is vim -y to make vim behave more like a "normal" editor than even nano :D (ie, you get ctrl-s and ctrl-q).
I used nano for about five years for git commits before I decided to embrace the Vim Way. No need to feel defensive about it, it's there for a reason.
<edited to remove pointless debate> To the rest of us, it boils down to "learn vim so you can prove you are a Real Hacker."
I acknowledge that knowing a thing I don't know (how to use vim to do anything useful) technically makes you smarter than me in the sense of 'possessing more knowledge about vim.' So, good for you. On the other hand, I don't accept that that knowledge is more useful than the knowledge of how to use literally any other good program that edits text. And I don't think anything should be that obtuse and seemingly intentionally non-obvious (onscreen visibility of important bindings or commands would aid in learning, and could be turned off by the true elite such as yourself, couldn't they?)
Funny, I find I do way less keystrokes in modal editors. I feel handicapped without. My patience runs out as soon as I have to use the arrows to fix something a few words back.
> - avoid even having to tell it I want to save. Of course I want to save. ^x - all done
ZZ and ZQ isn't very difficult. And shift is usually easier on the pinky than ctrl.
You don't have to like vim, that's ok, but there's no need to exaggerate when comparing. When I was new I was so terrified of getting stuck in vim that I learned to use the `-m` option in all my commits. I still use it, but with vim keys even in my shell because it's so useful.
> I do way less keystrokes in modal editors. I feel handicapped without. My patience runs out as soon as I have to use the arrows to fix something a few words back.
nano and micro do support lots of types of cursor movement (the same ^a and ^e emacs bindings that work across the mac os work fine, for instance. They also have word-forward and word-back) without resorting to hammering the arrow keys. And mouse support too, for the times when that makes more sense. And all of this without having modes, and with most of the bindings visible on screen (which there is more than enough room for in modern usage so I'm a big fan of that).
> ZZ and ZQ isn't very difficult.
Keeping track of what mode you're in is the primary reason it doesn't speak to me, is all. I haven't met many people (anecdotal disclaimer!!) who actually use vim by choice, compared to how many young developers I've met who seem to have been told they have to use it when using the Terminal, so they subsequently wrote down "ESC, :wq" on a sticky note, and get flummoxed if they accidentally do something wrong because they have no idea how to use it. I saw these developers actually shying away from using things like git cli -- they became afraid of editing text in a terminal due to the unforgiving vim learning curve.*
Of course, I also agree you don't have to dislike vim and am glad your expertness with it makes you more productive. I've seen several developers who have mastered vim zipping around multiple documents and who knows what, with great efficiency. (While I don't feel like I'm missing anything by using a GUI app for such tasks, I'm still very impressed by those people!) I just want you to know I don't dislike vim completely irrationally :)
* As an example, this very thread has about 5 vim experts who didn't even know about your neat ZZ and ZQ trick! If lots of pros don't even use vim as effectively as it's designed to be used, what hope do new users have?
> Keeping track of what mode you're in is the primary reason it doesn't speak to me, is all.
Both vim and neovim has the mode on the bottom unless you're in normal. I first started using vim to get away from electron apps eating my ram. But it clicked pretty quick and fixed my RSI among other things. Modal editing is underrated.
[alias]
lg = log --graph --abbrev-commit --decorate --date=format-local:'%Y-%m-%d %H:%M' --format=format:'%C(bold blue)%h%C(reset) | %C(bold green)%ad%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all -n 15
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --decorate --date=short
quick-push = "!f() { git add . && git commit -m \"$1\" && git push; }; f"
search = lg -E -i --grep
[user]
email = xxx
name = sandreas
[core]
ignorecase = false
autocrlf = input
excludesfile = ~/.gitignore_global
[url "https://github.com/"]
insteadOf = git@github.com:
[url "ssh://git@github.com/sandreas/"]
insteadOf = https://github.com/sandreas/
[url "ssh://git@github.com/sandreas/"]
insteadOf = git@github.com:sandreas/
The quick-push might be interesting. It calls a function `f`, which is defined before, to git add .
git commmit -m "$1"
git push
This can be used to define small git workflows as alias. [alias]
# show a list of local git branches sorted by the commit date
branches = "for-each-ref --sort=-committerdate refs/heads --format='%(authordate:short) %(color:yellow)%(objectname:short) %(color:green)%(refname:short)%(color:reset) (%(color:cyan)%(committerdate:relative)%(color:reset)) %(authorname)'"
# show a list of local and remote git branches sorted by the commit date
branches-remote = "for-each-ref --sort=-committerdate refs/heads refs/remotes --format='%(authordate:short) %(color:yellow)%(objectname:short) %(color:green)%(refname:short)%(color:reset) (%(color:cyan)%(committerdate:relative)%(color:reset)) %(authorname)'"I set EDITOR in my bashrc ages ago, so everything uses my chosen editor, including git. This git setting then overrides it if you use it.
No, it makes it sort by the committer date of the commit pointed to by the branch. Personally I find that to be of little use. To actually sort by recently used (i.e. switched-to), I wrote https://github.com/amarshall/git-recent-branches
```
alias gs='git status'
alias gl='git log'
alias gd='git diff --color-words'
alias ga='git add'
alias gc='git commit'
```
If an option is used by 80% of users, shouldn't it be the default, and have an option to turn it off for the 20%?
remote.origin.tagOpt=--tags
Now, is there any way to set that for all remotes? remote.*.tagOpts=--tags fatal: bad config line 11 in file /home/twic/src/myproject/git/gitconfighas been getting a lot of traction; it helps us not shy away from what we did.
if you think people who use "master" are doing so because they fervently wish to reconstitute slavery, you may be beyond help
even my woke friends who are somewhat rational cringe at this
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /private/tmp/test/.git/
I think people that set this actually get to that point because they don't want to keep seeing the warning, and "main" is as good a value as any. In light of this, your harsh moral ascription seems fairly silly.When I archive repos from Github, I keep track of which branch the API says is default. Otherwise there might be no way to figure it out in the future!
Also it's pretty sad that this is the only part of a very informative article that you deigned to comment about.
One repo uses `master` but a subtree uses `main`. If you make a mistake and checkout `main` you end up clobbering your whole working tree with the subtree.
I also have tooling that used to happily assume `master`, which worked fine 99% of the time. Now it works 50% of the time, and even worse the name of the main branch is just a convention, so you can't even read a setting to see which one to use.
I don't care about the specific name. `main` would definitely have made more sense from the start (classic terrible Git naming). But I do care about pointlessly changing it and breaking everything.
If you replace checkout with switch/restore, that foot gun goes away.
[alias]
checkout-default = "!git checkout $(git rev-parse --abbrev-ref origin/HEAD | sed 's@^origin/@@')"Also, wait until people find out about what "Spanish main" is (spoiler: still slavery).