Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git:如何在一个步骤中使文件看起来像其他提交中的文件?_Git_Patch - Fatal编程技术网

Git:如何在一个步骤中使文件看起来像其他提交中的文件?

Git:如何在一个步骤中使文件看起来像其他提交中的文件?,git,patch,Git,Patch,基本上,我想要的是 git diff HEAD branch1 -- foo.txt > patch.txt; git apply patch.txt 如何一步到位? 还有,附带问题:如何为文件指定掩码,例如,***.xml?您可以从分支(任何提交)中检出单个文件,如下所示: git checkout branch1--foo.txt您可以从分支(任何提交)中检出单个文件,如下所示: git签出分支1--foo.txt

基本上,我想要的是

git diff HEAD branch1 -- foo.txt > patch.txt;

git apply patch.txt
如何一步到位?


还有,附带问题:如何为文件指定掩码,例如,
***.xml

您可以从分支(任何提交)中检出单个文件,如下所示:


git checkout branch1--foo.txt

您可以从分支(任何提交)中检出单个文件,如下所示:

git签出分支1--foo.txt