0

I'm new to interactive rebasing in Git so I made a branch where I could squash commits ( squash-branch ) just in case I ruined something. I didn't change any of the files on the branch, just the history. I merged the branch to master expecting that it would take the commit new commit history of the squash-branch.

How do I replace the commit history of master with squash-branch's history? To say it in a different mood, I want master to have squash-branch's history.

I've already tried two methods of force overwriting master with squash-history. The "ours strategy" and git branch -f master squash-branch.

Please notify if you need more details!

Thanks!

JoeS
  • 41
  • 5
  • ...what? Do they have shared history? Do you mean you want to *rebase* `squash-branch` onto `master`? Or something else? Do you mean you were just practicing on a copy of master, in which case now you've been successful why not re-run the same process on master? Do you share that history with anyone else? – jonrsharpe Dec 30 '19 at 19:15
  • I genuinely wanted to squash commits on `master` and made `squash-branch` to do so safely. I guess I was just hoping for a way to get my history change on `squash-branch` over to `master` without redoing the same thing again on `master`. But, I maybe this misses the whole point of a branch having a commit history. Do you think force pushing `squash-branch` to `origin master` could do that? – JoeS Dec 30 '19 at 19:23

1 Answers1

2

git reset can do that:

git checkout master
git reset --soft squash-branch

Details in git-reset(1).

git reset [<mode>] [<commit>]

This form resets the current branch head to <commit>

Ry-
  • 218,210
  • 55
  • 464
  • 476