Some times you need to merge some specific commits into your branch

so here is what I usually do when I need this.

  1. creating a file that has all the info about this hash (patch)
    git format-patch -1 <commit_hash>
    
  2. check the changes applying
    git apply --check <changes.patch>
    

    If the result of git apply returns nothing then you can apply it.

  3. apply the commit
    git am -s <changes.patch>
    

    But If there are errors, then you have to apply it using 3-way merge So instead of doing the previous step you need to do the following

    git am -3 <changes.patch>
    
  4. Check the log conflicts or search for it.
  5. fix the conflicts and add them
    git add <changed_fix_conflict_files>
    
  6. continue the applying patch
    git am --continue