Created
March 12, 2020 08:29
-
-
Save wulucxy/fe9839ecf6f4bb9dc032ddd62f411380 to your computer and use it in GitHub Desktop.
git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usually use the -p flag with a git checkout from the other branch which I find easier and more granular than most other methods I have come across. | |
In principle: | |
git checkout <other_branch_name> <files/to/grab in/list/separated/by/spaces> -p | |
example: | |
git checkout mybranch config/important.yml app/models/important.rb -p | |
You then get a dialog asking you which changes you want in "blobs" this pretty much works out to every chunk of continuous code change which you can then signal y (Yes) n (No) etc for each chunk of code. | |
The -p or patch option works for a variety of commands in git including git stash save -p which allows you to choose what you want to stash from your current work | |
I sometimes use this technique when I have done a lot of work and would like to separate it out and commit in more topic based commits using git add -p and choosing what I want for each commit :) | |
------ | |
从其他分支里面按照文件路径来选择指定的文件 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment