Git-SVN:从集中式 SVN 服务器更新 Git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16857063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git-SVN: Update Git repo from centralized SVN server
提问by Jacob Krieg
I'm working on a project for which everyone uses SVN
as a centralized server and everybody pushes the changes they do on that server. I want to use Git
locally and I'm pretty new to git svn
. I did a git svn clone
of the repository with git svn clone -r HEAD https://svn.repo/app/branch
an I want to do an update through git.
我正在开发一个项目,每个人都将其SVN
用作中央服务器,并且每个人都在该服务器上推送他们所做的更改。我想在Git
本地使用,而且我对git svn
. 我做了一个git svn clone
存储库,git svn clone -r HEAD https://svn.repo/app/branch
我想通过 git 进行更新。
I need a 'git pull like' command but to pull from a specific revision of the SVN server repo. Also is there a 'fetch like' command to fetch from a specific revision of the SVN server repo?
我需要一个 'git pull like' 命令,但要从 SVN 服务器存储库的特定版本中提取。还有一个'fetch like'命令可以从SVN服务器存储库的特定版本中获取吗?
I don't have any .svn
folders in my cloned project and git remote
doesn't give me anything. However I did a git config -l
and I get the SVN server's URL, so somehow I'm linked with the SVN server. I don't know how to fetch or pull though.
我的.svn
克隆项目git remote
中没有任何文件夹,也没有给我任何东西。但是我做了一个git config -l
,我得到了 SVN 服务器的 URL,所以我以某种方式与 SVN 服务器链接。我不知道如何获取或拉动。
Thanks!
谢谢!
回答by bentolor
Best way to work on a Subversion Repository via Git:
通过 Git 处理 Subversion 存储库的最佳方式:
git svn init -s https://svn.repo/app/ myrepo
assuming that under https://svn.repo/app/the repo contains the standard/trunk
,branches
andtags
subdirectories- Do a
git svn fetch
in myrepo until no more commits are fetched (may take quite some time and sometimes aborts under Windows). - Checkout a specific Subversion branch or trunk via
git checkout -b trunk remotes/trunk
git svn init -s https://svn.repo/app/ myrepo
假设在https://svn.repo/app/ 下,repo 包含标准/trunk
,branches
和tags
子目录git svn fetch
在 myrepo 中执行,直到不再获取提交(可能需要相当长的时间,有时在 Windows 下会中止)。- 通过以下方式签出特定的 Subversion 分支或主干
git checkout -b trunk remotes/trunk
Then you can simply browse, hack and commit into your Git Repo containing all Subversion commits and branches.
然后,您可以简单地浏览、修改并提交到包含所有 Subversion 提交和分支的 Git 存储库。
- To pull in new commits from SVN use
git svn rebase
- To push your local commits into SVN use
git svn dcommit
- 要从 SVN 中提取新的提交,请使用
git svn rebase
- 将您的本地提交推送到 SVN 使用
git svn dcommit
To jump to a specific Subversion revision you only need to browse the history via git log
and search for a commit mirroring the according subversion commit. You can easily spot the Subversion revision in the git-svn-id:
line of the commit message. The just use a git checkout <commithash>
to explicitly checkout that version.
要跳转到特定的 Subversion 修订版,您只需浏览历史记录git log
并搜索反映相应 Subversion 提交的提交。您可以轻松地git-svn-id:
在提交消息的行中发现 Subversion 修订版。只需使用 agit checkout <commithash>
显式检出该版本。
回答by Guillaume Darmont
A good start :
一个好的开始:
To fetch new svn commit into your local repo : git svn rebase
获取新的 svn commit 到你的本地仓库: git svn rebase
To push your local commit to SVN : git svn dcommit
将您的本地提交推送到 SVN : git svn dcommit
You will probably have to use git stash
and git stash pop
, before using the two commands above when your working copy has uncommited changes.
当您的工作副本有未提交的更改时,您可能必须在使用上面的两个命令之前使用git stash
and git stash pop
。