[#git master/main aliases update]

alias gpom="git push origin master"


alias gpom="git push origin master 2> /dev/null || git push origin main"

so that if no `master` branch exists in the present repo, is retries with `main` instead

that was actually not such a great solution as the error messages can get confusing: I replaced it by the following functions

git branch -r | sed 's|.*/||' | grep -E 'main|master' --color=never | uniq

git push origin $(git_main_branch_name)

#git #main #branch #aliases

Show thread

@douginamug @jums I was reminded that there might be a simpler alternative framapiaf.org/@jums/1052571679 but can we really trust a command without at least 3 pipes?!?

@maxlath @douginamug as i mistakenly created a "master" on a "main" repo. new proposition:

gcom () {
[[ "$(git branch -l main)" =~ [[main]]*$ ]] && git check-out main
[[ "$(gb -l master)" =~ [[master]]*$ ]] && gco master

main is the first if do avoid the mistake above. regex is here to ensure branch name is not preprended with "* " in case the user is already on the branch in question (the sed function on max proposition)
Im sure there more improvment to make :)

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!