How to rewrite a specific file from a branch to a trunk in SVN?

How can I rewrite a file from a specific branch in the trunk?

Like, for example, I have an https: //web/trunk/text.cpp file. Then I want my https: //web/branches/tt_branch/text.cpp to overwrite the trunk line file.

+4
source share
3 answers

If you want to completely overwrite the trunk file with a forked file, you can delete the trunk file and then make a copy of the branch (simple and radical)

svn delete https://web/trunk/text.cpp -m "delete trunk file" svn copy https://web/branches/tt_branch/text.cpp 

If you want to do something less absolute try using svn merge

 svn merge https://web/branches/tt_branch/text.cpp https://web/trunk/text.cpp 

which asks you to resolve potential conflicts, if you do not want to resolve conflicts, try the following:

 svn merge --accept theirs-full https://web/branches/tt_branch/text.cpp https://web/trunk/text.cpp 
+5
source

Run the following command from a working copy of the trunk:

svn merge --accept theirs-full https: //web/branches/tt_branch/text.cpp

+2
source

I think the accepted answer is much better than the one I'm going to give, but svn cat may be useful in some situations where you do not want to interfere with the merge process and do not want to compress your commit history.

 svn cat https://web/branches/tt_branch/text.cpp > text.cpp 
+1
source

All Articles