Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

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

?

like image 991
Pablo Marin-Garcia Avatar asked Nov 28 '11 16:11

Pablo Marin-Garcia


1 Answers

In the form that you are mentioning, there is really no difference between the two and the --merge is superfluous.

--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.

Also, when you do git checkout --merge -- file during conflict, you get back the conflicted merge in file ( from the index)

The above two are the uses for --merge and in the form you mentioned, it is not different from git checkout some_branch -- file

like image 51
manojlds Avatar answered Nov 15 '22 03:11

manojlds