Answer the question
In order to leave comments, you need to log in
If I made several commits to the wrong branch in a hurry, is it possible to somehow selectively transfer them to another?
Well, for example, I forgot to switch, and made a couple of commits to the master.
Or, in general, in branch-1, but it was necessary in branch-2.
How can I resolve all this?
Thank you.
Answer the question
In order to leave comments, you need to log in
Depends on what kind of migration you want to do and what state of the branches are now
. Suppose you have this situation:
branch-1 A - B - C - D - E
branch-2 F
# переключаемся на нужный бранч
git checkout branch-2
# мержим бранч с коммитами
git merge branch-1
# переключаемся на бранч, в который случайно запушили
git checkout branch-1
# делает жесткий резет на 3 коммита назад (все, что мы сделали и на закомитили в ветке сотрется)
git reset --hard HEAD~3
# переключаемся на наш бранч
git checkout branch-2
branch-1 A - B
branch-2 F - C - D - E
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question