I
I
Igor Uvarov2014-11-17 20:24:12
git
Igor Uvarov, 2014-11-17 20:24:12

How to cut commits from one branch to another?

Good day! There was a situation with which I can not cope alone.
There is a master branch in the repository. I need to move some commits from this branch to the new one. But so that they are removed from master.
Hope the community can help. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Mishin, 2014-11-17
@kuflash

git checkout -b "branch-name" "commit-hash"
branch-name - branch name
commit-hash - commit hash code from which to branch. All commits that were later will not go into the new branch.
Example:
git checkout -b "new-branch" "ffe5069daa6d42e4f9e0efc28892e5401d42183f"

N
neolink, 2014-11-17
@neolink

first, with the help of git rebase -i HEAD~7,
re-sort your commits (just swap lines)
then cut off the tail - it turns out the master
in the test, you can rebase again, but just delete the extra lines

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question