How to cherry pick only changes for only one file, not the whole commit

后端 未结 9 1344
萌比男神i
萌比男神i 2020-12-04 07:12

I need to apply changes introduced in one branch to another branch. I can use cherry pick to do that. However, in my case I want to apply changes which are relevant only for

相关标签:
9条回答
  • 2020-12-04 07:32
    git reset HEAD~1
    

    moves the files into pre-commit stage

    git stash
    

    removes from memory

    Now your branch is pretty clean (reverted to previous commit)

    0 讨论(0)
  • 2020-12-04 07:38

    This is what are you looking for:

    git checkout target-branch sha1 path/to/file
    

    sha1 is optional

    0 讨论(0)
  • 2020-12-04 07:39

    Git has everything ready :)

    Just use git checkout <sha> <path-to-file>

    0 讨论(0)
提交回复
热议问题