Skip to content

Commit 56926b9

Browse files
committed
add optional commit delete upon rebase
1 parent a5b4448 commit 56926b9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

gitspread.sh

100644100755
+12
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ function split_commits_to_branches() {
8484
# Push the new branch to the remote repository
8585
git push origin "$branch_name"
8686

87+
# Optionally delete the commit from the old branch
88+
echo "Do you want to delete the commit from the original branch? (y/n)"
89+
read -n 1 -r delete_commit < /dev/tty
90+
91+
if [[ "$delete_commit" == "y" || "$delete_commit" == "Y" ]]; then
92+
git checkout "$original_branch"
93+
94+
# Remove the commit using a rebase
95+
git rebase --autostash --onto "$commit_hash"^ "$commit_hash"
96+
git push origin "$original_branch" --force
97+
fi
98+
8799
# Optionally, create a pull request using a CLI tool like GitHub CLI
88100
# Uncomment the line below if you have GitHub CLI installed
89101
# gh pr create --base main --head "$branch_name" --title "$commit_message"

0 commit comments

Comments
 (0)