Jeremy Harris
Jeremy Harris

Reputation: 24579

SVN merge local trunk into branch

Disclaimer: I'm relatively new to SVN. Most of my experience is with GIT.

We have a production site with all the code on an SVN trunk. I have a checked out copy that I have been making some changes to. We decided to create a branch for the feature I am building. I went ahead and checked out the branch as well. Now I have a local copy of the trunk with my changes that I need to merge into my local copy of the branch. Once I do that, I am going to discard the local trunk copy as I don't want my changes to be pushed to the production trunk.

How would I go about merging code from a local SVN folder into another local SVN folder?

P.S. I develop on Ubuntu 12.04. I have SVN Workbench installed (but I haven't really used it) and do most of my svn work via command line. If there is a linux GUI that would help with this, I'm ok with that as well.

Upvotes: 7

Views: 2285

Answers (4)

maxim1000
maxim1000

Reputation: 6375

  1. Switch your working copy with changes to the branch
  2. Commit

Upvotes: 2

Greg
Greg

Reputation: 12847

Create a diff of your changes in trunk, then apply that to your branch.

cd trunk
svn diff > ../the-branch/yourchanges.diff
svn revert -R .
cd ../the-branch
svn patch yourchanges.diff

If patch doesn't like that you're in a different branch, you can use the unix patch command

patch -p0 < yourchanges.diff

That'll get you mostly there, but won't delete files (it will truncate them) and won't preserve svn property changes.

Upvotes: 1

Dmitry Pavlenko
Dmitry Pavlenko

Reputation: 8978

As your experience to Git is larger as SVN's experience and you think in DVCS style, you may use SmartGit as an SVN client. It works like git-svn but honestly translates full branches and cherry-picking merges, ignores, EOL-handling properties, externals and tags (what git-svn does not).

Upvotes: 1

Maxime
Maxime

Reputation: 1816

Well, because SVN is not a DCVS, you cannot do that without : - Losing your history, - Or commiting into the central repository.

I assume you know how to perform a merge with the central repository.

If you don't mind losing your history, you should create a local svn repository and import your local version of the trunk in it. Checkout this repo and copy you local branch file into it. Perform the merge and recommit the result into the remote repository.

But again, if your everyday workflow implies to have a local staging area, you may switch to Git or Mercurial.

Bye.

Upvotes: 0

Related Questions