简体   繁体   English

用另一个分支中的同一文件替换git分支中的文件?

[英]replacing a file in a git branch with the same file from another branch?

Every time I update one of my git repo and fetch a new branch or commits I want to replace two of the new files with the ones in a specific branch. 每当我更新我的一个git repo并获取一个新的分支或提交时,我想用特定分支中的那些替换两个新文件。

I know that I can do that with checkout but... 我知道我可以通过结账来做到这一点,但......

What is the difference between 有什么区别

git checkout wanted_branch file_wanted

and

git checkout --merge wanted_branch file_wanted

?

In the form that you are mentioning, there is really no difference between the two and the --merge is superfluous. 在你提到的形式中,两者之间确实没有区别,而且--merge是多余的。

--merge option is mainly used when you are switching branches and you have local modifications in your working directory, so that rather than just saying you cannot switch branches, you can make git to attempt to do a three-way merge on the modifications and present you with checked out branch with or without the conflicts. --merge选项主要用于切换分支并且在工作目录中进行本地修改时,不要只是说你不能切换分支,你可以让git尝试对修改进行三向合并。向您展示有或没有冲突的签出分支。

Also, when you do git checkout --merge -- file during conflict, you get back the conflicted merge in file ( from the index) 此外,当你这样做git checkout --merge -- file冲突期间,你回来的冲突合并file (从索引)

The above two are the uses for --merge and in the form you mentioned, it is not different from git checkout some_branch -- file 以上两个是--merge ,在你提到的形式中,它与git checkout some_branch -- file没有区别git checkout some_branch -- file

暂无
暂无

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

相关问题 我可以将来自 Git 分支的文件与 Sublime 中另一个 Git 分支的相同文件进行比较吗 - Can I compare a file from a Git branch with the same file of another Git branch in Sublime Git:如何将一个文件从分支 A 的更改应用到同一 repo 的分支 B 中的另一个文件? - Git: How to apply changes of one file from branch A to another file in branch B of the same repo? 将Java类文件从git中的一个分支移动到另一分支 - Move a java class file from one branch in git to another branch Git 将文件从现有分支删除到另一个现有分支 - Git remove a file from existing branch to another existing branch 从git分支中删除文件,但保留在另一个文件中? - Remove a file from a git branch but keep it in another? Git 使用来自不同分支的相同文件覆盖 master 中的文件 - Git Overwrite file in master with same file from different branch 将git rm -f <file>从另一个分支中删除该文件 - Will git rm -f <file> remove the file from another branch 从分支获取文件到GIT - Getting a file from a branch into GIT Git的。 将更改从一个文件合并到同一分支中的另一个文件 - Git. Merging changes from one file to another files WITHIN the same branch 使用 git,如何从另一个分支中的文件(绕过合并)强制覆盖一个分支中的文件并提交? - With git, how to force overwrite a file in one branch, from a file in another branch (bypass merge), and commit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM