Use oh-my-zsh aliases for git. They are amazing, and thanks to those aliases I speed up and precise my git work significantly! I don't use anymore git status, just do gst. Otherwise when I want to list all commits in branch I simply do glol, and have beautiful color branch graph.Many of you may think this is counter-productive to install and/or remember another aliases/commands which are not native in shell. I kindly do not agree - I use git too often a day to type full commands, or click it in IDEs GUI via mouse/trackpad.Many of colleagues use only or mostly the GUI interface integrated within their IDEs. tbh I'm not huge fan of this, as you must learn the IDEs - without it you can't do anything (on server it may become a problem, right?). I've also tried to force myself to only commit via IDE, but this works for simple committing, if you need to rebase or squash this start to being a problem. Using git via console give me huge advantage to be able to work in every environment whether it's Linux, macOS or Windows.
Fetch all repos from any directory
Below bash function will help you git fetch for all the repos from current path or given path (must be absolute path).
sh
# fetch all repos from current path or given path (must be absolute path)function fetchAllRepos () { local destPath=${1} if [[ -z "${destPath}" ]]; then # current path with all symbolic links resolved destPath=$(pwd -P) fi printf "Requested destination path to search through: %s\n\n" $destPath find ${destPath} -name .git -type d -prune | xargs -S1024 -I {} sh -c 'cd {} && cd .. && printf "\n>>>>>> Repository: %s\n" $(realpath) && printf "Current branch: %s\n" $(git rev-parse --abbrev-ref HEAD) && git fetch && if [[ -z "$(git status --porcelain)" ]]; then git pull; fi'}
Update all git repositories from current path
Take current directory (.) and search for all git repositories underneath (not nested) and fetch the latest changes from the origin.
sh
find . -name .git -type d -prune | xargs -I {} sh -c 'cd {} && cd .. && printf "Repo: %s\n\n" $(realpath) && git fetch'
Change master branch to main
Change master to main, push to origin and clean afterwards.
(Optional) update the default branch in repo settings.