Git copy file from another branch without staging it

前端 未结 2 907
执念已碎
执念已碎 2021-01-06 09:01

I\'ve found how you can copy a file wholesale from one branch to another:

Edit please note, if you think this question is a duplicate

相关标签:
2条回答
  • 2021-01-06 09:30

    You can use git restore

    git restore --source feature-B directory/somefile.php

    I didn't pass any option saying where it should restore the file and by befault it's working directory (without index/staging area). From documentation:

    > -W
    > --worktree
    > -S
    > --staged
    > 
    >     Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying --staged will only restore the index. Specifying both restores both.
    
    0 讨论(0)
  • 2021-01-06 09:33

    you could use git show and then redirect... it's not very elegant, though

    git show feature-B:directory/somefile.php > directory/somefile.php
    
    0 讨论(0)
提交回复
热议问题