S
S
Sergey Gladyshev2018-04-09 08:56:24
git
Sergey Gladyshev, 2018-04-09 08:56:24

Git. Move multiple commits from one branch to another.?

Good day.
I forgot to branch from master , made some changes to the code, and pushed a couple of commits.
After that, I forked from master and now I'm on the task branch.
How can I move the last two commits from master to the current branch?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanovskiy, 2018-04-09
@Sanovskiy

GIT rebase
You need to change the commit that your branch is branching from.

I
iRedds, 2018-04-09
@iRedds

For example:
git checkout master
git reset --soft HEAD~2
git checkout task
git commit -a -m "a new commit containing the changes from the last two commits from the master"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question