Replacing a file in git branches with the same file from another branch?

Every time I update one of my git repositories and select a new branch or comment, I want to replace two new files with the ones indicated in a particular branch.

I know I can do this with validation, but ...

What's the difference between

git checkout wanted_branch file_wanted 

and

 git checkout --merge wanted_branch file_wanted 

?

+4
source share
1 answer

In the form you mention, there is no difference between the two and --merge . This is superfluous.

--merge option is mainly used when you switch branches, and you have local changes in your working directory, so instead of just saying that you cannot switch branches, you can make git try to make a three-way merge of the changes and present to you a verification branch with or without conflicts.

Also, when you do git checkout --merge -- file during a conflict, you return a conflicting merge to file (from the index)

The above two are used for --merge and in the form you specify, this is no different from git checkout some_branch -- file

+3
source

Source: https://habr.com/ru/post/1383458/


All Articles