I would like to create a single commit that will make the current branch identical in contents (and implicitly in sync) with another branch.
This is practically the equivalent of copy pasting the checkout contents of another branch on top of the current branch and committing everything in one go.
$ git reset --hard <another branch>
$ git reset --soft HEAD@{1}
$ git commit
The first (hard) reset grabs the contents of the other branch into your working directory. The second (soft) reset puts your commit pointer back at the tip of your original branch, but doesn't change the files in your index at all, thus leaving them as they were in the other branch. You can then commit that state on top of your current branch's latest commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With