Ladiko
Ladiko

Reputation: 279

How to merge two branches in git

I have a branch with name development. I made 4 commits and I needed to revert back to the first commit but while preserving these 4 commits. So I checked out the first commit as new branch development_back. Now I would like to merge these two branches, I do not want to continue in development_back branch but in development branch. Is it doable somehow?

Upvotes: 2

Views: 96

Answers (1)

Kirill
Kirill

Reputation: 3454

IF I understand you correctly you currently have this:

A -> B -> C -> D -> E
^                   ^
development_back    development

But want to get this:

A -> B -> C -> D -> E
                    ^ development
                    ^ development_back

If it is correct then all you need is to merge development into development_back, not in the opposite way. So checkout development_back branch and do git merge --ff-only development. --ff-only flag ensures that you the merge will be fast-forward.

Upvotes: 1

Related Questions