简体   繁体   English

Git svn:如何使用“部分”分支?

[英]Git svn: how do I work with “partial” branches?

By "partial", I mean the branches in my SVN repository were not copied from trunk/, but from a subdirectory of trunk/. “部分”是指我的 SVN 存储库中的分支不是从 trunk/ 复制的,而是从 trunk/ 的子目录复制的。 Here's the svn repo layout:这是 svn 存储库布局:

trunk/
    core
    projectA
    projectB
    ...
branches/
    core_new_feature (branched from "core" on trunk)
    another_branch
    ...

I have inited my local repository and fetched:我已经初始化了我的本地存储库并获取了:

mkdir git-svn-repo
cd git-svn-repo
git svn init -s svn+ssh://me@svn-server/path/to/repository
git fetch
<wait four days>

Now I'm trying to work on the "core_new_feature" branch.现在我正在尝试处理“core_new_feature”分支。 git branch -a shows: git 分支 -a 显示:

* master
remotes/core_new_feature
... (a bunch of other branches)

So I try:所以我尝试:

git checkout --track -b git_new_feature remotes/core_new_feature

Git checks out files, and appears to be working. Git 检出文件,似乎正在工作。 Yet when I try to browse my freshly checked out branch (ls local-git-root/core/), I get weirdness.然而,当我尝试浏览我新签出的分支(ls local-git-root/core/)时,我感到很奇怪。 Specifically, I don't see my source code or any of the existing changes on the core_new_feature SVN branch.具体来说,我没有看到我的源代码或 core_new_feature SVN 分支上的任何现有更改。 All I see under core/ are a few empty directories, a seemingly random smattering of my exiting source tree under core.我在 core/ 下看到的只是一些空目录,似乎是我在 core 下现有的源代码树的零星。

However, the "core_new_feature" source is available under local-git-root/src/ - it's just right there in the root of my git repository.但是,“core_new_feature”源在 local-git-root/src/可用 - 它就在我的 git 存储库的根目录中。 projectA and projectB from above have disappeared.上面的 projectA 和 projectB 已经消失了。

What I need is for the changes on the "core_new_feature" svn branch to go to the correct location (namely local-git-root/core/), and for the other projects to not disappear我需要的是更改“core_new_feature”svn 分支到 go 到正确的位置(即 local-git-root/core/),并且其他项目不会消失

Clearly I'm missing some crucial step here, but I've looked through all the examples I could find, and none seems to deal with this issue.显然我在这里遗漏了一些关键步骤,但我已经查看了所有我能找到的示例,似乎没有一个可以解决这个问题。 Maybe I need to set up my local repository differently?也许我需要以不同的方式设置我的本地存储库?

For reference, here's my.git/config file:作为参考,这里是 my.git/config 文件:

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
        hideDotFiles = dotGitOnly
[svn-remote "svn"]
        url = svn+ssh://me@svn-server/path/to/repository
        fetch = repository/trunk:refs/remotes/trunk
        branches = repository/branches/*:refs/remotes/*
        tags = repository/tags/*:refs/remotes/tags/*
[branch "core_new_feature"]
        remote = .
        merge = refs/remotes/core_new_feature

My repository uses the standard branches/ tags/ trunk/ layout.我的存储库使用标准的分支/标签/主干/布局。 I ran the commands using the git-bash shell that msysgit provides.我使用 msysgit 提供的 git-bash shell 运行命令。 Version is 1.7.4.版本是 1.7.4。

Thanks in advance for any assistance.提前感谢您的任何帮助。

I haven't used git-svn myself, but markjaquith has a good post on how he uses it to manage his commits for his WordPress development.我自己没有使用过 git-svn,但是 markjaquith 有一篇很好的文章,介绍了他如何使用它来管理他的 WordPress 开发的提交。 You might consider skimming it to see if he mentions anything useful.你可以考虑略读一下,看看他是否提到了任何有用的东西。 I've had it tucked away for the next time I update one of my WordPress plugins, or create a new one (everything WordPress is on svn).下次我更新我的 WordPress 插件或创建一个新插件(WordPress 都在 svn 上)时,我已经把它藏起来了。

http://markjaquith.wordpress.com/2011/05/26/developing-on-wordpress-using-git/ http://markjaquith.wordpress.com/2011/05/26/developing-on-wordpress-using-git/

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

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