If you want to create a new commit on top of your brancha commits (that you want to keep), reflecting origin/master, I would suggest a reset --hard then soft (as in "Practical uses of git reset --soft
?").
m--m--m (origin/master)
\
a--a--a (brancha, HEAD)
First, reset the index and worktree to what you want to see: origin/master
git checkout brancha
git branch tmp
git reset --hard origin/master
m--m--m (origin/master, brancha, HEAD)
\
a--a--a (tmp)
Problem: brancha
history is not longer referenced: move brancha
HEAD back to its original position, but without changing the index and working tree (which both reflect origin/master
)
git reset --soft tmp
m--m--m (origin/master)
\
a--a--a (tmp, brancha, HEAD)
Now you can add and commit: that should compute the relevant delta to set a new commit with the same content as origin/master
.
git add .
git commit -m "Restore origin/master content in a new commit on brancha"
m--m--m (origin/master)
\
a--a--a----M (brancha, HEAD)
(tmp)
M
and origin/master commit should have the same content.