简体   繁体   English

Git-SVN:从集中式SVN服务器更新Git repo

[英]Git-SVN: Update Git repo from centralized SVN server

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. 我正在开发一个项目,每个人都使用SVN作为集中式服务器,每个人都推动他们在该服务器上所做的更改。 I want to use Git locally and I'm pretty new to git svn . 我想在本地使用Git ,我对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. 我做了一个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. 我需要一个'git pull like'命令,但要从SVN服务器repo的特定版本中提取。 Also is there a 'fetch like' command to fetch from a specific revision of the SVN server repo? 还有一个'fetch like'命令从SVN服务器repo的特定修订版中获取?

I don't have any .svn folders in my cloned project and git remote doesn't give me anything. 我的克隆项目中没有任何.svn文件夹, git remote也没有给我任何东西。 However I did a git config -l and I get the SVN server's URL, so somehow I'm linked with the SVN server. 但是我做了一个git config -l ,我得到了SVN服务器的URL,所以不知怎的,我已经与SVN服务器链接了。 I don't know how to fetch or pull though. 我不知道如何取或拉。

Thanks! 谢谢!

Best way to work on a Subversion Repository via Git: 通过Git在Subversion资源库上工作的最佳方式:

  1. git svn init -s https://svn.repo/app/ myrepo assuming that under https://svn.repo/app/ the repo contains the standard /trunk , branches and tags subdirectories git svn init -s https://svn.repo/app/ myrepo假设在https://svn.repo/app/下 ,repo包含标准/trunkbranchestags子目录
  2. Do a git svn fetch in myrepo until no more commits are fetched (may take quite some time and sometimes aborts under Windows). 在myrepo中执行git svn fetch ,直到不再提取提交(可能需要相当长的时间,有时在Windows下中止)。
  3. Checkout a specific Subversion branch or trunk via git checkout -b trunk remotes/trunk 通过git checkout -b trunk remotes/trunk特定的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 Repo。

  • To pull in new commits from SVN use git svn rebase 要从SVN git svn rebase新提交,请使用git svn rebase
  • To push your local commits into SVN use git svn dcommit 要将本地提交推送到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. 要跳转到特定的Subversion修订版,您只需要通过git log浏览历史git log并搜索镜像相应的subversion提交的提交。 You can easily spot the Subversion revision in the git-svn-id: line of the commit message. 您可以在提交消息的git-svn-id:行中轻松发现Subversion修订版。 The just use a git checkout <commithash> to explicitly checkout that version. 只需使用git checkout <commithash>来显式检出该版本。

A good start : 一个好的开始:

To fetch new svn commit into your local repo : git svn rebase 要获取新的svn提交到您的本地repo: 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 stashgit stash pop ,然后在使用上述两个命令时,当您的工作副本具有未经修改的更改时。

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

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