Quick (and messy) svn merge branch to trunk

Posted on

It seems that whenever I need to merge changes from a branch back into the trunk of a project I am working on in SVN its always a hassle. I am usually working on projects solo and dont really care about tracking changes over time, I just want it to WORK! I dont need to merge multiple versions etc… I just want the HEAD of branch to go to HEAD of trunk and commit. Other times I might have some changes in trunk that I would like to keep, but in this case I dont. A simple thing to do you’d think, but only if you can remember the commands.

I am approaching the problem this way because if you really need all of that fancy “merge multiple revisions” junk there are better tools for the job, Git, mercurial, Bazaar etc… I use subversion for small simple projects and dont want to spend more time working with my version control system than I do my code.


# First checkout the trunk that you want to eventually hold the changes:
svn co https://localhost/svn/project/trunk/ ./project_trunk

# Change directory to trunk
cd ./project_trunk

# Merge changes from branch into current working copy
svn merge --reintegrate --accept=theirs-full https://localhost/svn/project/branches/name_of_branch

###############################################################
# SKIP THIS IF YOU WOULD LIKE TO MANUALLY FIGURE OUT CONFLICTS
# Mark all changes in the working copy as valid
svn resolve --accept=working -R .
###############################################################

#Commit your changes
svn commit -m "Just merged branch back into trunk"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s