Rebase experimental branches

0

Fake everyone (including yourself) by squashing stupid commits on your experimental branch and then merging a pristine commit to master

git checkout -b crazy-experiment

do lots of stupid commits on that branch and once you finally have a good commit at the end

git rebase -i master

Git will open a text file for you to interaction choose what to do. Remember "squash" melds the commit into the previous one (the one in the line before)

reword b4760d7 done             
squash d679e69 almost there
squash fe568a8 im so tired                         
squash 8423b49 f this
squash 0c508c5 what the heck 

# Rebase 55f0191..ac7be85 onto 55f0191
amazing and pristine code             

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Sun Aug 9 08:54:43 2020 -0700
#
# interactive rebase in progress; onto 55f0191

merge and delete the branch

git checkout master
git merge crazy-experiment
git branch -d crazy-experiment

https://www.atlassian.com/git/tutorials/merging-vs-rebasing

and

https://stackoverflow.com/questions/8939977/git-push-rejected-after-feature-branch-rebase

this will give a similar result

git checkout crazy-experiment
git reset --soft master
git commit -m "amazing experiment"
git checkout master
git merge crazy-experiment
git branch -d crazy-experiment

  • 0 posts
  • 0 subtopics
  • about 2 months ago by vince