How to merge a specific commit in Git

后端 未结 7 1318
攒了一身酷
攒了一身酷 2020-11-22 01:41

I have forked a branch from a repository in GitHub and committed something specific to me. Now I found the original repository had a good feature which was at HEAD

7条回答
  •  迷失自我
    2020-11-22 02:03

    Let's try to take an example and understand:

    I have a branch, say master, pointing to X , and I have a new branch pointing to Y .

    Where Y = branch commits - few commits

    Now say for Y branch I have to gap-close the commits between the master branch and the new branch. Below is the procedure we can follow:

    Step 1:

    git checkout -b local origin/new
    

    where local is the branch name. Any name can be given.

    Step 2:

      git merge origin/master --no-ff --stat -v --log=300
    

    Merge the commits from master branch to new branch and also create a merge commit of log message with one-line descriptions from at most actual commits that are being merged.

    For more information and parameters about Git merge, please refer to:

    git merge --help
    

    Also if you need to merge a specific commit, then you can use:

    git cherry-pick 
    

提交回复
热议问题