Posted 10 months ago. Visible to the public.
Git shortcut to rebase onto another branch
Inspired by recent "git shortcut" cards I figured it would be nice to have one of these for rebasing a few commits onto another branch. The usual notation is prone to of-by-one errors as you have to either specify the commit before the ones you want to move or count the number of commits.
You may add this rebase-onto
function to your ~/.bashrc
:
Copyfunction rebase-onto { commit=$(git log --oneline | fzf --prompt 'Select the first commit you want to move' | awk '{print $1}') branch=$(git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ | fzf --prompt 'Select the branch to rebase onto' | awk '{print $1}') test_command="git rebase -i --onto $branch $commit~" read -p "Execute command '$test_command' (Y/n)? " choice case "$choice" in n|N ) echo "aborted.";; * ) eval "$test_command";; esac }
It should reduce the amount of brain cells involved when rebasing onto a branch:
See the first card below for more context on this example.
See also
- Git: rebase dependent feature branch after squash
- Git shortcut to fixup a recent commit
- Git shortcut to checkout recent branches
Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).