Skip to content

Instantly share code, notes, and snippets.

@nektro
Last active March 24, 2024 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nektro/0a332803e43ebca6d5924eb68f981279 to your computer and use it in GitHub Desktop.
Save nektro/0a332803e43ebca6d5924eb68f981279 to your computer and use it in GitHub Desktop.
actualrandom() {
cat /dev/urandom | head -c $1 | xxd -ps | awk '{printf "0x" $0}' | xargs -0 printf "%d\n"
}
git-newbranchname() {
rand=$(actualrandom 2)
echo "nektro-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