简体   繁体   English

将现有的 Git 存储库推送到 SVN

[英]Pushing an existing Git repository to SVN

I've been doing all my work in Git and pushing to GitHub.我一直在 Git 做我所有的工作,并推到 GitHub。 I've been very happy with both the software and the site, and I have no wish to change my working practices at this point.我对软件和网站都非常满意,目前我不想改变我的工作习惯。

My PhD adviser is asking all students to keep their work in an SVN repository that's hosted at the university.我的博士导师要求所有学生将他们的工作保存在大学托管的 SVN 存储库中。 I've found tons of documentation and tutorials about to pull down an existing SVN repository into Git, but nothing about pushing a Git repository to a fresh SVN repository. I've found tons of documentation and tutorials about to pull down an existing SVN repository into Git, but nothing about pushing a Git repository to a fresh SVN repository. I expect there must be some way to do this with a combination of git-svn and a fresh branch and rebasing and all those wonderful terms, but I'm a Git newbie and don't feel confident with any of them.我希望必须有某种方法可以结合 git-svn 和一个新的分支和 rebase 以及所有这些美妙的术语来做到这一点,但我是一个 Git 新手,对其中任何一个都没有信心。

I then want to just run a couple of commands to push commits to that SVN repository when I choose.然后,当我选择时,我只想运行几个命令将提交推送到该 SVN 存储库。 I wish to keep using Git and just have the SVN repository mirror what's in Git.我希望继续使用 Git 并让 SVN 存储库镜像 Git 中的内容。

I'll be the only person ever committing to SVN, if this makes any difference.如果这有什么不同的话,我将是唯一一个致力于 SVN 的人。

I needed this as well, and with the help of Bombe's answer + some fiddling around, I got it working.我也需要这个,在 Bombe 的回答 + 一些摆弄的帮助下,我得到了它的工作。 Here's the recipe:这是食谱:

Import Git -> Subversion导入 Git -> 颠覆

1. cd /path/to/git/localrepo
2. svn mkdir --parents protocol:///path/to/repo/PROJECT/trunk -m "Importing git repo"
3. git svn init protocol:///path/to/repo/PROJECT -s
4. git svn fetch
5. git rebase origin/trunk
5.1.  git status
5.2.  git add (conflicted-files)
5.3.  git rebase --continue
5.4.  (repeat 5.1.)
6. git svn dcommit

After #3 you'll get a cryptic message like this:在 #3 之后,您将收到一条如下所示的神秘消息:

Using higher level of URL: protocol:///path/to/repo/PROJECT => protocol:///path/to/repo使用更高级别的 URL: protocol:///path/to/repo/PROJECT => protocol:///path/to/repo

Just ignore that.忽略这一点。

When you run #5, you might get conflicts.当你运行#5 时,你可能会遇到冲突。 Resolve these by adding files with state "unmerged" and resuming rebase.通过添加 state “未合并”的文件并恢复变基来解决这些问题。 Eventually, you'll be done;最终,您将完成; then sync back to the SVN repository, using dcommit .然后使用dcommit同步回 SVN 存储库。 That's all.就这样。

Keeping repositories in sync保持存储库同步

You can now synchronise from SVN to Git, using the following commands:您现在可以使用以下命令从 SVN 同步到 Git:

git svn fetch
git rebase trunk

And to synchronise from Git to SVN, use:要从 Git 同步到 SVN,请使用:

git svn dcommit

Final note最后说明

You might want to try this out on a local copy, before applying to a live repository.在应用到实时存储库之前,您可能想在本地副本上尝试一下。 You can make a copy of your Git repository to a temporary place;您可以将您的 Git 存储库复制到一个临时位置; simply use cp -r , as all data is in the repository itself.只需使用cp -r ,因为所有数据都在存储库本身中。 You can then set up a file-based testing repository, using:然后,您可以使用以下方法设置基于文件的测试存储库:

svnadmin create /home/name/tmp/test-repo

And check a working copy out, using:并检查工作副本,使用:

svn co file:///home/name/tmp/test-repo svn-working-copy

That'll allow you to play around with things before making any lasting changes.这将允许您在进行任何持久更改之前玩弄事物。

Addendum: If you mess up git svn init附录:如果你搞砸了git svn init

If you accidentally run git svn init with the wrong URL, and you weren't smart enough to take a backup of your work (don't ask...), you can't just run the same command again.如果你不小心用错误的 URL 运行git svn init ,并且你不够聪明,无法备份你的工作(不要再问同样的命令......) You can however undo the changes by issuing:但是,您可以通过发出以下命令撤消更改:

rm -rf .git/svn
edit .git/config

And remove the section [svn-remote "svn"] section.并删除部分[svn-remote "svn"]部分。

You can then run git svn init anew.然后您可以重新运行git svn init

Here's how we made it work:以下是我们如何使它工作的:

Clone your Git repository somewhere on your machine.在您机器上的某处克隆您的 Git 存储库。

Open .git/config and add the following (from Maintaining a read-only SVN mirror of a Git repository ):打开.git/config并添加以下内容(来自维护 Git 存储库的只读 SVN 镜像):

[svn-remote "svn"]
    url = https://your.svn.repo
    fetch = :refs/remotes/git-svn

Now, from a console window, type these:现在,从控制台 window 输入这些:

git svn fetch svn
git checkout -b svn git-svn
git merge master

Now, if it breaks here for whatever reason, type these three lines:现在,如果它由于某种原因在此处中断,请键入以下三行:

git checkout --theirs .
git add .
git commit -m "some message"

And finally, you can commit to SVN:最后,您可以提交 SVN:

git svn dcommit

Note: I always scrap that folder afterwards.注意:我总是在之后废弃那个文件夹。

Using git rebase directly will lose the first commit.直接使用git rebase会丢失第一次提交。 Git treats it different and can't rebase it. Git 对待它不同,不能变基。

There is a procedure that will preserve full history: http://kerneltrap.org/mailarchive/git/2008/10/26/3815034有一个程序可以保留完整的历史记录: http://kerneltrap.org/mailarchive/git/2008/10/26/3815034

I will transcribe the solution here, but credits are for Björn.我将在此处转录解决方案,但归功于 Björn。

Initialize git-svn:初始化 git-svn:

git svn init -s --prefix=svn/ https://svn/svn/SANDBOX/warren/test2

The --prefix gives you remote tracking branches like "svn/trunk" which is nice because you don't get ambiguous names if you call your local branch just "trunk" then. --prefix 为您提供远程跟踪分支,如“svn/trunk”,这很好,因为如果您将本地分支称为“trunk”,您不会得到模棱两可的名称。 And -s is a shortcut for the standard trunk/tags/branches layout. -s是标准主干/标签/分支布局的快捷方式。

Fetch the initial stuff from SVN:从 SVN 获取初始内容:

git svn fetch

Now look up the hash of your root commit (should show a single commit):现在查找根提交的 hash(应该显示单个提交):

git rev-list --parents master | grep '^.\{40\}$'

Then get the hash of the empty trunk commit:然后得到空trunk commit的hash:

git rev-parse svn/trunk

Create the graft:创建嫁接:

git replace --graft <root-commit-hash> <svn-trunk-commit-hash>

Now, "gitk" should show svn/trunk as the first commit on which your master branch is based.现在,“gitk”应该将svn/trunk显示为您的主分支所基于的第一个提交。

Make the graft permanent:使移植物永久化:

git filter-branch -- ^svn/trunk --all

Drop the graft:放下移植物:

git replace -d <root-commit-hash>

gitk should still show svn/trunk in the ancestry of master. gitk 仍应在 master 的祖先中显示svn/trunk

Linearize your history on top of trunk:在主干上线性化您的历史记录:

git svn rebase

And now "git svn dcommit -n" should tell you that it is going to commit to trunk.现在“git svn dcommit -n”应该告诉你它将提交到主干。

git svn dcommit

Create a new directory in the Subversion repository for your project.在 Subversion 存储库中为您的项目创建一个新目录。

# svn mkdir --parents svn://ip/path/project/trunk

Change to your Git-managed project and initialize git-svn.切换到你的 Git 管理的项目并初始化 git-svn。

# git svn init svn://ip/path/project -s
# git svn fetch

This will create a single commit because your SVN project directory is still empty.这将创建一个提交,因为您的 SVN 项目目录仍然是空的。 Now rebase everything on that commit, git svn dcommit and you should be done.现在重新基于该提交, git svn dcommit ,你应该完成。 It will seriously mess up your commit dates, though.但是,它会严重扰乱您的提交日期。

Git -> SVN with complete commit history Git -> SVN 具有完整的提交历史

I had a Git project and had to move it to SVN.我有一个 Git 项目,不得不将其移至 SVN。 This is how I made it, keeping the whole commit history.我就是这样做的,保留了整个提交历史。 The only thing that gets lost is the original commit time since libSVN will set the local time when we do git svn dcommit .唯一丢失的是原始提交时间,因为当我们执行git svn dcommit时,libSVN 将设置本地时间。

Howto:如何:

  1. Have a SVN repository where we want to import our stuff to and clone it with git-svn:有一个 SVN 存储库,我们想在其中导入我们的东西并使用 git-svn 克隆它:

     git svn clone https://path.to/svn/repository repo.git-svn`
  2. Go there: Go 那里:

     cd repo.git-svn
  3. Add the remote of the Git repository (in this example I'm using C:/Projects/repo.git ).添加远程 Git 存储库(在此示例中,我使用C:/Projects/repo.git )。 You want to push to SVN and give it the name old-git:您想推送到 SVN 并将其命名为 old-git:

     git remote add old-git file:///C/Projects/repo.git/
  4. Fetch the information from the master branch from the old-git repository to the current repository:从旧 git 存储库的 master 分支获取信息到当前存储库:

     git fetch old-git master
  5. Checkout the master branch of the old-git remote into a new branch called old in the current repository:将 old-git 远程的 master 分支检出到当前存储库中名为 old 的新分支中:

     git checkout -b old old-git/master`
  6. Rebase to put the HEAD on top of old-git/master.变基以将 HEAD 放在 old-git/master 之上。 This will maintain all your commits.这将维护您的所有提交。 What this does basically is to take all of your work done in Git and put it on top of the work you are accessing from SVN.这基本上是将您在 Git 中完成的所有工作放在您从 SVN 访问的工作之上。

     git rebase master
  7. Now go back to your master branch:现在 go 回到你的主分支:

     git checkout master

    And you can see that you have a clean commit history.你可以看到你有一个干净的提交历史。 This is what you want to push to SVN.这就是您要推送到 SVN 的内容。

  8. Push your work to SVN:将您的工作推送到 SVN:

     git svn dcommit

That's all.就这样。 It is very clean, no hacking, and everything works perfectly out of the box.它非常干净,没有黑客攻击,一切都开箱即用。 Enjoy.享受。

I would propose a very short instruction in 4 commands using SubGit .我会使用SubGit在 4 个命令中提出一个非常简短的指令。 See this post for details.有关详细信息,请参阅此帖子

I needed to commit my existing Git repository to an empty SVN repository.我需要将现有的 Git 存储库提交到一个空的 SVN 存储库。

This is how I managed to do this:这就是我设法做到这一点的方法:

$ git checkout master
$ git branch svn
$ git svn init -s --prefix=svn/ --username <user> https://path.to.repo.com/svn/project/
$ git checkout svn
$ git svn fetch
$ git reset --hard remotes/svn/trunk
$ git merge master
$ git svn dcommit

It worked without problems.它没有问题。 I hope this helps someone.我希望这可以帮助别人。

Since I had to authorize myself with a different username to the SVN repository (my origin uses private/public key authentication), I had to use the --username property.由于我必须使用 SVN 存储库的不同用户名授权自己(我的origin使用私钥/公钥身份验证),因此我必须使用--username属性。

Yet another sequence that worked (with some comments on each step):另一个有效的序列(每个步骤都有一些评论):

  1. Install git-svn and subversion toolkits:安装git-svnsubversion工具包:

     sudo apt-get install git-svn subversion
  2. Switch inside the PROJECT_FOLDERPROJECT_FOLDER内切换

    cd PROJECT_FOLDER
  3. Create the project path on the Subversion server (unfortunately the current git-svn plugin has a defect in comparison with TortoiseSVN).在 Subversion 服务器上创建项目路径(不幸的是,当前的git-svn插件与 TortoiseSVN 相比存在缺陷)。 It is unable to store source code directly into the PROJECT_FOLDER .它无法将源代码直接存储到PROJECT_FOLDER中。 Instead, by default, it will upload all the code into PROJECT_FOLDER/trunk .相反,默认情况下,它将所有代码上传到PROJECT_FOLDER/trunk

    svn mkdir --parents protocol:///path/to/repo/PROJECT_FOLDER/trunk -m "creating git repo placeholder" svn mkdir --parents protocol:///path/to/repo/PROJECT_FOLDER/trunk -m "创建 git repo 占位符"

This is the place where trunk at the end of the path is mandatory这是路径末端的trunk强制性的地方

  1. Initialize the git-svn plugin context inside the .git folder初始化.git文件夹内的git-svn插件上下文

    git svn init -s protocol:///path/to/repo/PROJECT_FOLDER

    This is the place where trunk at the end of the path is unnecessary这是路径尽头不需要trunk的地方

  2. Fetch an empty Subversion repository information获取一个空的Subversion存储库信息

    git svn fetch

    This step is helping to synchronize the Subversion server with the git-svn plugin.此步骤有助于将 Subversion 服务器与git-svn插件同步。 This is the moment when git-svn plugin establishes remotes/origin path and associates it with the trunk subfolder on the server side.这是git-svn插件建立remotes/origin路径并将其与服务器端的trunk子文件夹相关联的时刻。

  3. Rebase old Git commits happened before the git-svn plugin became involved in the process (this step is optional )对旧的 Git 提交进行变基,该提交发生在git-svn插件参与该过程之前(此步骤是可选的)

     git rebase origin/trunk
  4. Add new/modified files to commit (this step is regular for Git activities and is optional )添加新的/修改的文件以提交(此步骤对于 Git 活动是常规的,并且是可选的)

     git add.
  5. Commit freshly added files into the local Git repository (this step is optional and is only applicable if step 7 has been used):将新添加的文件提交到本地 Git 存储库(此步骤是可选的,仅在使用了第 7 步时才适用):

     git commit -m "Importing Git repository"
  6. Pushing all the project changes history into the Subversion server:将所有项目更改历史推送到 Subversion 服务器:

     git svn dcommit

If you want to keep on working with Git as your main repository and just need to "export" the revisions to SVN from time to time, you could use Tailor to keep the SVN repository in sync.如果您想继续使用 Git 作为您的主存储库,并且只需要不时“导出”对 SVN 的修订,您可以使用Tailor来保持 SVN 存储库同步。 It can copy revisions between different source control systems and would update the SVN with the changes you make in Git.它可以在不同的源代码控制系统之间复制修订,并会使用您在 Git 中所做的更改来更新 SVN。

I haven't tried a Git-to-SVN conversion, but for a SVN -> SVN example see this answer .我还没有尝试过 Git 到 SVN 的转换,但是对于 SVN -> SVN 示例,请参阅此答案

If you don't have to use any specific SVN and you are using GitHub you can use their SVN connector.如果您不必使用任何特定的 SVN 并且您正在使用 GitHub 您可以使用他们的 SVN 连接器。

More information is here: Collaborating on GitHub with Subversion更多信息在这里: 与 Subversion 合作 GitHub

I recently had to migrate several Git repositories to SVN, and after trying all solutions I could find, what finally worked for me was Mercurial (yes, using a third VCS).我最近不得不将几个 Git 存储库迁移到 SVN,在尝试了我能找到的所有解决方案之后,最终对我有用的是Mercurial (是的,使用第三个VCS) Using this guide , I came up with the following process (on Linux, but the basic idea should work on Windows as well).使用本指南,我想出了以下过程(在 Linux 上,但基本思想也适用于 Windows)。

  1. The necessary packages:必要的软件包:

     $ sudo apt-get install git subversion mercurial python-subversion
  2. Mercurial needs to be configured by adding the following to ~/.hgrc : Mercurial 需要通过将以下内容添加到~/.hgrc来进行配置:

     [extensions] hgext.convert=
  3. Create some temporary working directories (I had several repositories to migrate so I created directories for the SVN and Git versions, to keep them separate):创建一些临时工作目录(我有几个要迁移的存储库,因此我为 SVN 和 Git 版本创建了目录,以保持它们分开):

     $ mkdir svn $ mkdir git
  4. Make an empty local SVN repository:创建一个空的本地 SVN 存储库:

     $ svnadmin create svn/project
  5. Clone the existing Git repository:克隆现有的 Git 存储库:

     $ git clone server/path/project.git git/project
  6. Let Mercurial do its thing:让 Mercurial 做它的事:

     $ hg convert --dest-type svn git/project svn/project
  7. Now the SVN repository should contain the full commit history, but not with original timestamps.现在 SVN 存储库应该包含完整的提交历史记录,但不包含原始时间戳。 If this is not an issue, skip over the next part to step 11.如果这不是问题,请跳过下一部分到步骤 11。

  8. With a little work, the date and time of each commit can be changed .只需一点点工作,就可以更改每次提交的日期和时间 Since my repositories are fairly small, it was feasible for me to do it manually.由于我的存储库很小,因此我可以手动完成。 First, create a pre-revprop-change hook in the SVN repository with the following contents, to allow the necessary property to be modified:首先,在 SVN 存储库中创建一个pre-revprop-change挂钩,其中包含以下内容,以允许修改必要的属性:

     #;/bin/bash exit 0;

    This script has to be made executable:这个脚本必须是可执行的:

     $ chmod +x svn/project/hooks/pre-revprop-change
  9. Mercurial created a working copy of the SVN repository, named project -wc, so switch to it and edit the commit times: Mercurial 创建了 SVN 存储库的工作副本,命名为project -wc,因此切换到它并编辑提交时间:

     $ cd project-wc $ svn propedit svn:date --revprop -r 1

    Enter the correct date and time (pay attention to timezones.) and save: You should get a message saying "Set new value for property svn.date on revision 1".输入正确的日期和时间(注意时区。)并保存:您应该会收到一条消息,提示“在修订版 1 上为属性 svn.date 设置新值”。
    Now rinse and repeat for every other revision.现在冲洗并重复每个其他版本。

  10. Optionally check the commit history to make sure everything looks OK: (可选)检查提交历史以确保一切正常:

     $ svn log -r 1:HEAD

    Then go back up one level:然后 go 备份一级:

     $ cd..
  11. Dump the repository:转储存储库:

     $ svnadmin dump svn/project > project.dump
  12. And load the dump on your Subversion server.并在您的 Subversion 服务器上加载转储。 Done!完毕!

This process would probably also work directly between remote repositories, but I found it easier to work with local ones.这个过程可能也可以直接在远程存储库之间工作,但我发现使用本地存储库更容易。 Fixing the commit times was a lot of work, but overall the process was much more straightforward than any other method I found.修复提交时间需要做很多工作,但总体而言,这个过程比我发现的任何其他方法都简单得多。

there are three methods:有三种方法:

  1. rebase: as the other answers rebase:和其他答案一样

  2. commit id: find svn first commit id and git first commit id, echo their into.git/info/grafts: echo "git_id svn_id}" >.git/info/grafts then git svn dcommit commit id: find svn first commit id and git first commit id, echo their into.git/info/grafts: echo "git_id svn_id}" >.git/info/grafts then git svn dcommit

  3. checkout every git commit,copy files into svn_repo, svn commit检查每个 git 提交,将文件复制到 svn_repo,svn 提交

bash demo: github demo bash 演示: github 演示

v1.x: use rebase and commit id v1.x:使用rebase和commit id

v2.x: use copy files,then svn commit v2.x:使用复制文件,然后 svn 提交

You can make a new SVN repository.您可以创建一个新的 SVN 存储库。 Export your Git project (fleshing out the.git files).导出您的 Git 项目(充实 .git 文件)。 Add it to the SVN repository (initializing the repository with what you had so far in Git).将其添加到 SVN 存储库(使用您目前在 Git 中的内容初始化存储库)。 Then use the instructions for importing SVN repositories in a fresh Git project.然后使用说明在新的 Git 项目中导入 SVN 存储库。

But this will lose your previous Git history.但这会丢失您之前的 Git 历史记录。

I would like to share a great tool being used in the WordPress community called Scatter我想分享一个在 WordPress 社区中使用的很棒的工具,叫做 Scatter

Git WordPress plugins and a bit of sanity scatter Git WordPress 插件和一些理智分散

This enables users to be able to send their Git repository to wordpress.org SVN automatically.这使用户能够自动将其 Git 存储库发送到 wordpress.org SVN。 In theory, this code can be applied to any SVN repository.理论上,此代码可以应用于任何 SVN 存储库。

I just want to share some of my experience with the accepted answer.我只是想与接受的答案分享我的一些经验。 I did all steps and all was fine before I ran the last step:在运行最后一步之前,我完成了所有步骤,一切都很好:

git svn dcommit

$ git svn dcommit $ git svn dcommit

Use of uninitialized value $u in substitution (s///) at /usr/lib/perl5/vendor_perl/5.22/Git/SVN.pm line 101.在 /usr/lib/perl5/vendor_perl/5.22/Git/SVN.pm 第 101 行使用未初始化的值 $u 替换 (s///)。

Use of uninitialized value $u in concatenation (.) or string at /usr/lib/perl5/vendor_perl/5.22/Git/SVN.pm line 101. refs/remotes/origin/HEAD: ' https://192.168.2.101/svn/PROJECT_NAME ' not found in ''在 /usr/lib/perl5/vendor_perl/5.22/Git/SVN.pm 第 101 行的连接 (.) 或字符串中使用未初始化的值 $u。refs/remotes/origin/HEAD: ' https://192.168.2.101/ svn/PROJECT_NAME '未在 '' 中找到

I found the thread https://github.com/nirvdrum/svn2git/issues/50 and finally the solution which I applied in the following file in line 101 /usr/lib/perl5/vendor_perl/5.22/Git/SVN.pm我找到了线程https://github.com/nirvdrum/svn2git/issues/50 ,最后找到了我在第 101 行/usr/lib/perl5/vendor_perl/5.22/Git/SVN.pm的以下文件中应用的解决方案

I replaced我换了

$u =~ s!^\Q$url\E(/|$)!! or die

with

if (!$u) {
    $u = $pathname;
} 
else {
       $u =~ s!^\Q$url\E(/|$)!! or die
      "$refname: '$url' not found in '$u'\n";
}

This fixed my issue.这解决了我的问题。

In my case, I had to initiate a clean project from SVN就我而言,我必须从 SVN 启动一个干净的项目

$ Project> git svn init protocol://path/to/repo -s
$ Project> git svn fetch

add all your project sources...添加所有项目源...

$ Project> git add .
$ Project> git commit -m "Importing project sources"
$ Project> git svn dcommit

This is what I would do.这就是我会做的。 Assuming my local branch is called main .假设我的本地分支称为main Fill in the gaps, cause I do not remember the exact git svn commands, as I have not used it in a while.填补空白,因为我不记得确切的git svn命令,因为我有一段时间没有使用它了。

  • create in svn the branch that will be used for the project.在 svn中创建将用于项目的分支。
  • use git svn to clone the svn repo you want (at least, the branch you want to use so that you do not have to fetch the other millions of revisions that we do not care about for this endeavor).使用git svn克隆您想要的 svn 存储库(至少,您要使用的分支,这样您就不必为我们不关心的其他数百万个修订而获取)。
  • checkout the svn branch in the new git repo.在新的 git 存储库中查看 svn 分支。
  • Add to this repository a remote that points to the original git repo you are using for the project.将指向您用于项目的原始git 存储库的远程添加到此存储库。 Let's say the remote is called the-real-stuff .假设遥控器被称为the-real-stuff
  • git fetch the-real-stuff # so that we get to see what's in the real repo git fetch the-real-stuff # 这样我们就可以看到真正的 repo 中有什么
  • Given that this is the first time we will be pulling our code into the svn one, we have to trick git so that it can "merge" that code: git merge --allow-unrelated-histories the-real-stuff/main -m "Whatever comment I want in the svn revision" .鉴于这是我们第一次将我们的代码拉入 svn 一个,我们必须欺骗 git 以便它可以“合并”该代码: git merge --allow-unrelated-histories the-real-stuff/main -m "Whatever comment I want in the svn revision" This will "merge" both branches locally.这将在本地“合并”两个分支。
  • git svn dcommit so that you can push the content of the project as it is right now. git svn dcommit以便您可以按原样推送项目内容。

Continue working on the original git repo.继续处理原始git 存储库。 Then, when you want to push into svn, go to the git svn clone and do:然后,当你想推入 svn,go 到 git ZAF04A1AA0E00F476768E60309 克隆和 do:AAAEE5

git fetch the-real-stuff # get visibility to the changes in the original git repo
git merge the-real-stuff/main -m "Whatever comment I want to show on this svn revision"
git svn dcommit

And you are done.你完成了。

I like the idea of using 2 repos so that we do not fill out the original repo with svn stuff, though it's possible to keep the whole thing in a single git repo.我喜欢使用 2 个存储库的想法,这样我们就不会用 svn 的东西填写原始存储库,尽管可以将整个东西保存在一个 git 存储库中。

What if you don't want to commit every commit that you make in Git, to the SVN repository?如果您不想将在 Git 中所做的每个提交提交到 SVN 存储库怎么办? What if you just want to selectively send commits up the pipe?如果您只想选择性地发送提交到 pipe 怎么办? Well, I have a better solution.好吧,我有一个更好的解决方案。

I keep one local Git repository where all I ever do is fetch and merge from SVN.我保留了一个本地 Git 存储库,我所做的只是从 SVN 获取和合并。 That way I can make sure I'm including all the same changes as SVN, but I keep my commit history separate from the SVN entirely.这样我可以确保我包含与 SVN 相同的所有更改,但我将提交历史记录与 SVN 完全分开。

Then I keep a separate SVN local working copy that is in a separate folder.然后我在一个单独的文件夹中保留一个单独的 SVN 本地工作副本。 That's the one I make commits back to SVN from, and I simply use the SVN command line utility for that.那是我提交回 SVN 的那个,我只是为此使用 SVN 命令行实用程序。

When I'm ready to commit my local Git repository's state to SVN, I simply copy the whole mess of files over into the local SVN working copy and commit it from there using SVN rather than Git. When I'm ready to commit my local Git repository's state to SVN, I simply copy the whole mess of files over into the local SVN working copy and commit it from there using SVN rather than Git.

This way I never have to do any rebasing, because rebasing is like freebasing.这样我就不必做任何变基,因为变基就像自由变基。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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