简体   繁体   English

如何正确使用Git SVN?

[英]How Can I Do Git SVN Correctly?

In a work environment, our version control is Subversion, and that's unlikely to change. 在工作环境中,我们的版本控制是Subversion,并且不太可能更改。 I want to use Git locally, mostly for the advantage of local repositories. 我想在本地使用Git,主要是为了利用本地存储库。

Context 语境

Base URL: http://www.example.com/code (with ./trunk , ./branches , ./tags ). 基本网址: http://www.example.com/code (与./trunk,./branches,./tags)。

Using TortoiseGit, I was able to specify which one to check out. 使用TortoiseGit,我可以指定要签出的那个。 I'd like to have all branches, tags, and trunk available locally. 我想在本地提供所有分支机构,标签和中继。 This means, I'd be able to merge from a local branch back into a master, based on one of the remote branches if required. 这意味着,如果需要的话,我可以基于一个远程分支从本地分支合并回到主分支。

How do I do this correctly? 如何正确执行此操作?

After this long process completed, I tried to rebase to remotes/branches/EXAMPLE-BRANCH1 using TortoiseGit's 'SVN Rebase', going from master to remotes/branch/test-branch . 在完成这一漫长的过程之后,我尝试使用TortoiseGit的“ SVN Rebase”将基准迁移到remotes / branch / EXAMPLE-BRANCH1 ,从master转移到remotes/branch/test-branch This failed, saying that master was way behind. 失败了,说主人落后了。

When I tried going from master to a local branch based on remotes/branch/test-branch , the merge didn't work. 当我尝试从master转到基于remotes/branch/test-branch的本地remotes/branch/test-branch ,合并不起作用。

To clone your repo including all trunk/branches/tags with the standard layout (as you mention you have): 要克隆您的存储库,包括具有标准布局的所有主干/分支/标签(如您所述):

git svn clone -s http://www.example.com/code new-repo-directory

NOTE: Using git is not a silver bullet. 注意:使用git并非万能的。 You will still have merge/rebase conflicts that you will need to resolve. 您仍然需要解决合并/变基冲突。 You will probably have much less of them, but they will not go away entirely. 您可能会少很多,但它们不会完全消失。 The failure was probably accurate and indicates that you need to resolve the conflicts then finish your rebase with git rebase --continue . 该故障可能是准确的,表明您需要解决冲突,然后使用git rebase --continue完成git rebase --continue

I'm sure Tortoise is a great help for many things. 我敢肯定,龟甲在很多事情上都能提供很大的帮助。 But I've been told many times over that you will get much more out of git if you learn to use the command line (and I believe I agree) and only use GUI helpers as tools once you understand what it is they are doing behind the scenes. 但是我多次被告知,如果您学会使用命令行(我相信我同意),并且在您了解GUI助手的工作方式之后,才将GUI帮助程序用作工具,将会从git中获得更多收益。现场。

PS -- git svn rebase is for applying changes made in SVN on top of your current SVN tracked branch. PS- git svn rebase用于将SVN中所做的更改应用到当前SVN跟踪分支的顶部。 If you are trying to merge 2 different SVN tracked branches you will want to use git checkout branch-to-update then git rebase branch-with-updates (and resolve any conflicts, then git add the-conflicted-file and git rebase --continue until it is finished). 如果您尝试合并2个不同的SVN跟踪分支,则需要使用git checkout branch-to-update然后使用git rebase branch-with-updates (并解决所有冲突,然后git add the-conflicted-filegit rebase --continue直到完成)。

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

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