简体   繁体   English

git checkout到特定目录

[英]Git checkout to specific directory

So, currently I am working on merging two branches, A and B . 因此,目前我正在合并两个分支AB

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 . 我正在合并到分支B ,但是我已经将项目重组到了不同的目录,并且想要进行git checkout A --path/fileToGet各种操作(打算覆盖),但是进入了分支中另一个目录 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? 为了使修订历史记录文件,这将是最好的事情,我只是签像正常的文件, rm我目前的文件,然后git mv (或者也许只是一个普通的mv ,也许git会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. 我在SO的一些评论中发现,当使用git diff A:path/file B:anotherPath/file我能够比较两个文件,因此我认为可能还有另一种方法,使用:指定在哪里,到哪里。

rm当前目录,然后使用git checkout A --path/to/old/location签出旧文件位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM