Stash changes to specific files

前端 未结 5 1734
情话喂你
情话喂你 2020-12-01 01:23

I have a large git project that I, stupidly, imported to eclipse and ran an autoformat on. Now, every file in the project is showing as modified. Rather than commit my for

5条回答
  •  抹茶落季
    2020-12-01 01:49

    That's a good use for git diff and git apply IMO:

    git diff file2.cpp file2.h file3.cpp > ../my-changes.patch
    git checkout ...
    git apply ../my-changes.patch
    

    After diff, you can inspect the patch file to make sure that all your changes are there.

    Note that you may need to use the --reject option to apply, in case the patch does not apply cleanly. Also see the man page for apply.

提交回复
热议问题