Skip to content

Instantly share code, notes, and snippets.

@reconbot
Created April 3, 2025 15:51
Show Gist options
  • Save reconbot/b7e7381007949ac0b23e66751b284ba3 to your computer and use it in GitHub Desktop.
Save reconbot/b7e7381007949ac0b23e66751b284ba3 to your computer and use it in GitHub Desktop.
My git workflow commands
# git checkout main then branch - used to make a new branch from the head of main
gcmb () {
git checkout $(git_detect_main_branch) && git pull origin $(git_detect_main_branch) --ff-only && git checkout -b reconbot/$1
}
# git checkout main pull - go back to main
gcmp: aliased to git checkout $(git_detect_main_branch) && git pull origin $(git_detect_main_branch) --ff-only
# git rebase origin main - move your branch to start from the tip of main
grom: aliased to git fetch && git rebase --autostash origin/$(git_detect_main_branch)
# what it says on the tin, see if main then master are branches - so this stuff works even on old repos
git_detect_main_branch () {
git branch -l --format '%(refname:short)' main master | head -n 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment