Git签出到特定目录 [英] Git checkout to specific directory
问题描述
A
和 B
。 我正在合并到分支 B
中,但我已将项目重构为不同的目录,并希望执行 git checkout一个--path / fileToGet
的排序(覆盖就是这个意图),但进入我的分支不同的目录。为了保持文件的修订历史记录,最好的办法是,我是否像正常一样签出文件, rm
我的当前文件,然后是 git mv
(或者也许只是一个普通的 mv
,也许git会跟着它呢?还是有更好的方法可以跟踪?
我在SO的一些评论中发现,当使用 git diff A:path / file B:anotherPath / file
我能够比较这两个文件,所以我想可能有另一种方式,使用:
来指定从哪里到哪里。
<解决方案
rm
当前目录然后使用 git checkout A --path / to / old / location
检查旧文件位置。
So, currently I am working on merging two branches, A
and B
.
I'm merging into branch B
, but I had restructured the project into different directories and would like to do a git checkout A --path/fileToGet
of sorts (to overwrite is the intention) but into a different directory in my branch. To keep revision history for the file, what would be the best thing, do I just checkout the file like normal, rm
my current file and then git mv
(or maybe just a regular mv
and maybe git will follow` it? Or is there a better method to follow?
I had found in some comments here at SO that when using git diff A:path/file B:anotherPath/file
I am able to compare the two files, so I'm thinking there might be another way, using the :
to specify from where, to where.
rm
the current directory and then used git checkout A --path/to/old/location
to check the old file location out.
这篇关于Git签出到特定目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!