Skip to content

Instantly share code, notes, and snippets.

@layerok
Last active September 29, 2025 10:54
Show Gist options
  • Select an option

  • Save layerok/4688dec10e333372522a5d398df83e73 to your computer and use it in GitHub Desktop.

Select an option

Save layerok/4688dec10e333372522a5d398df83e73 to your computer and use it in GitHub Desktop.
custom git commands
// inspired by: https://mlog.nektro.net/
git-newbranchname() {
rand=$(actualrandom 2)
echo "vova-patch-${rand}"
}
git-newbranch() {
git checkout -b $(git-newbranchname)
}
git-commit2pr() {
current=$(git branch --show-current)
newone=$(git-newbranchname)
patchfile=$(git format-patch HEAD~1)
git reset --merge HEAD~1
git checkout -q origin/main
git checkout -b ${newone}
git am --reject ${patchfile}
git checkout ${current}
echo "Made new branch ${newone}"
echo "New current HEAD:"
git --no-pager log --oneline HEAD...HEAD~1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment