[#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

Afficher le fil de discussion

@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 :)

Inscrivez-vous pour prendre part à la conversation

Le réseau social de l'avenir : Pas d'annonces, pas de surveillance institutionnelle, conception éthique et décentralisation ! Possédez vos données avec Mastodon !