Search code examples
gitgitkraken

Git : How can change past commit from master branch to other branch?



I had weak of git knowledge.
I have one brach named 4.4.8. and I want modify 1fxxxx commit on master branch.
Master branch already had other version commit.
I don't know how can merge past commit from master to other branch.

--- Branch structure --

4.4.8 branch -- commit1 (current) commit2

master branch -- 1fxxxx - merge remote tracking branch origin/4.4.8 ---


Solution

  • You could do a rebase.

    git checkout master
    git rebase 4.4.8
    

    However, if there are any conflicts, you'll have to resolve them at this point. This will not create a merge commit.

    OR

    You could do merge,

    git checkout master
    git merge 4.4.8
    

    If there are conflicts, you will have to resolve them. Here is a good beginner's tutorial for that. A merge commit will be created in case it was not a clean merge.