简体   繁体   中英

Set up a working copy under both Git and Svn version control

For reasons I will not go into explaining (unless required) I have two repos, a subversion and a git one, where my project (identical copies of it) is located. I need to keep it this way, if possible.

Hence, what I would like to accomplish in order to maintain consistency between the two, is to set up a directory on my machine where I can svn checkout the project, work on it, and then push the changes to both the svn and the git repos.

I have read something about the git svn command but from what I gathered it only serves as a way to use git locally and then push (rather, dcommit ) your work to the svn repo. Nonetheless, I naively tried issuing: git svn init <url to svn repo> -s --username <uid> test (did not prompt for pwd, did not checkout working copy, only created folder .git inside folder test) followed by: git svn clone <url to git repo> test and it returned:

svn-remote.svn.url already set: <url to svn repo>
wanted to set to: <url to git repo>

However, my hopes are high thanks to this post here on SO: How to deal with Git-svn when have to use both Git and Subversion where it looks like the OP's workflow consists of both git svn dcommit and git push commands. If there is a way to accomplish what I wish, could someone please instruct me step by step on how to do it?

Thanks in advance.

PS As an added bonus of this peculiar configuration, I would like to be able to svn:ignore a certain folder of my project but have it pushed on the git repo (ie the img/local folder must not be committed to svn since there is a rule saying it should be ignored, but there is no such entry in the .gitignore file, so I assume that files added to it will be pushed to the git repo, but not to the svn one, right?)

The post you reference would require as simple a bootstrap as:

  • moving your .git folder in the root directory of your svn local workspace
  • examine the output of a git status , and see if you need to add anything to your .gitignore .

The other option would be to use a dedicated tool, specialized in the round-trip synchronization of svn-git repos, like SubGit (presented on GitMinutes episode 22 ).
But then, the working spaces (one for git, one for svn) would still be separate.

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