Skip to content

Instantly share code, notes, and snippets.

@rsitze
rsitze / gitp
Last active October 3, 2022 04:45
Find nearest (in commit history) parent branch of a given base branch using regex patterns for likely parent branch names. See https://stackoverflow.com/a/68673744/1448212
#!/usr/local/bin/bash
# For a walk through of what this does, how it works,
# see: https://stackoverflow.com/a/68673744/1448212
# git show-branch supports 29 branches; reserve 1 for current branch
GIT_SHOW_BRANCH_MAX=28
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
@rsitze
rsitze / gitr
Last active August 6, 2021 16:58
Find nearest (in commit history) related branch(es) given a base branch. See https://stackoverflow.com/a/68673744/1448212
#!/usr/local/bin/bash
# For a walk through of what this does, how it works,
# see: https://stackoverflow.com/a/68673744/1448212
# git show-branch supports 29 branches; reserve 1 for current branch
GIT_SHOW_BRANCH_MAX=28
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"