简体   繁体   中英

How to make a fork of an project into a local SVN repository?

  • I want to have a copy of an open source project in a local SVN repository.
  • I want to commit changes to my repository, but not to the central repository of the open source project.
  • I want to see the updates coming from the open source projects repository and review them.
  • If I like those changes I want to put them into my local repository.

  • Which ways can I go, to satisfy these requirements?

  • Which way is the best and why?

Will the SVN history of the open source project stay availible inside my repository whith those ways?

Thanks in advance.

Have a look at this StackOverflow Topic and answer: Correct workflow for managing a private Subversion fork. I have a very similar problem to yours and I am going to proceed using the git-svn [bridge aluded to in the accepted answer]. See also Git and Other Systems - Git and Subversion

Main Approach Advantage: This way you can always use SVN as the "back end", final repository.

I hope this helps. Love and peace,

As it was suggested by gbjbaanb, you have to use Vendor Branches and stay it pure Subversion

You can (have to) add to described in book workflow one small detail:

  • If upstream project also handled by Subversion
  • If you can reach project's repository from location of your own server

you can link part of upstream repo (/trunk ???) into vendor's branch of your repo (using svn:externals). This way you can

  • Monitor upstream activity ( svn up , svn log )
  • Have own independent from upstream mainline on own server
  • Integrate upstream changes into your code, using usual merge

I don't think there is a way of achieving that only with SVN. What you want is some sort of decentralized version control system, like Git or Mercurial.

I don't know if you've already work with one of them, but you can achieve what you want with both.

Here's some step to my idea (from a Mercurial point of view, but this will be quite identical with Git) :

  1. Init a mercurial repository ( hg init in an empty directory)
  2. Checkout the svn repository
  3. Add all the files to the mercurial repository ( hg addremove )
  4. Commit the changes to the mercurial repository ( hg commit -m "initial commit" )
  5. Clone the mercurial repository somewhere else ( hg clone /path/to/myrepo . in an empty directory)

You can now work in this mercurial clone and commit in it. However it's really important to never push the changes in the original mercurial repository.

For updating the SVN repository, follow these steps :

  1. In the SVN checkout : svn update
  2. Still in the SVN checkount hg addremove; hg commit -m "svn update" hg addremove; hg commit -m "svn update"
  3. In the workind directory (mercurial clone) : hg pull; hg merge; hg commit -m "merging svn update" hg pull; hg merge; hg commit -m "merging svn update"

For this to work, the working directory must be clean, ie all the changes must have been committed.

Basically, what we're a doing is using Mercurial as some sort of proxy to the SVN repository. You can commit to the local Mercurial clone without ever modifying the original source and still update from SVN and then merge theses changes in the local Mercurial clone.

I don't exactly know how to reproduce theses steps with Git, but I know it's also possible. You can even any other dvcs if you know one of them.

I totally agree that this solution is a bit complicated, but I never found an easier way to achieve this. I worked like this for 9 month with a CVS repository as a source and never had a problem.

However, if you've never heard of dvcs, git or mercurial, I strongly advised that you read some documentation, because theses steps are pretty complicated and things can go wrong pretty fast.

Hope this help.

EDIT:

You can also use SVN externals , but you won't be able to review and choose the modifications you want to import in your repository .

You will have to set a svn:externals property on a directory with :

svn propedit externals adirectory

Which will open an editor to let you edit the externals for the adirectory directory. Here you add a line for each external repository you wand to checkout in this directory like this (for each line) :

path/where/tocheckout    http://svn.example.com/repos/project

The next time you'll do an update, the svn repository will be checkouted in the given directory, with the full history.

(it's a long time since I used svn:externals, maybe some of the explanation is wrong, but it'll probably enough to get the big picture)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM