Reputation: 11334
I am working on a local git repository that doesn't have a configured remote one just yet. I accidentally started all my work on the local master
branch.
There are 22 commits so far and except the first two commits, I'd like all commits >=3rd onward to be "moved" to a new branch and then merged back into master so that the log shows a "merge commit" instead.
I tried this but didn't seem to work:
On master:
$ git branch new_branch
$ git reset HEAD~20
$ git add . && git stash
$ git merge --squash new_branch
$ git commit
This does get me a squashed merge commit and I now see only 3 commits on my master. However, if I do git log --merges
it doesn't output anything.
How can I create a "real merge commit" for the code in new_branch
that is detectable by git log --merges
and would list all commits if I were to run: git rev-list <merge-commit-id>^..<merge-commit-id>
?
Upvotes: 0
Views: 185
Reputation: 774
git merge --no-ff new_branch
instead of git merge --squash new_branch
Upvotes: 2
Reputation: 30212
Assuming you are back to where your problem was started, you could do it like this:
git checkout id-of-second-revision
git merge --no-ff master -m "use a proper comment"
git branch -f master # place master on this revision
git checkout master
And you are done.
Upvotes: 2