Which remote branches are my local git-svn branches bound to?

≯℡__Kan透↙ 提交于 2019-12-23 04:25:09

问题


I have the following .config file in my clone repo using git-svn:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[svn-remote "svn"] 
    url = https://svn.domain.com:8443/svn
    fetch = trunk:refs/remotes/trunk
    branches = branches/{some_branch}:refs/remotes/branches/*

When I do git branch -a, I get:

$ git branch -a
* master
  remotes/branches/some_branch
  remotes/trunk

How do I know which remote the local master branch is bound to (tracking)? Note that it seems this answer must be specific to git-svn since the normal git solutions (e.g. git remote show origin) do not work.

EDIT
After reading my question more closely I am not sure it makes sense. Basically I just want to know which SVN branch 'master' is bound to. I assumed remotes were branches, but they are actually just URLs to other repos AFAIK. So, what I really want is the mapping between remote SVN branch & local branch.


回答1:


what I really want is the mapping between remote SVN branch & local branch.

The answer is: There is none (at least not in the usual sense).

To elaborate:

Normally, in git you have two types of branches

  • regular (local) branches
  • remote-tracking branches

A local branch can be linked to (and a copy of) a remote-tracking branch (possibly with changes) - then the remote-tracking branch is called the "upstream branch" of the local branch. This "upstream relationship" is stored in the repo config (.git/config), and is visible in the output of git branch -vv.

Now the thing is: git-svn does not have this concept of an upstream branch.

In particular, it does not store an upstream relationship in the git config, and thus commands like git branch -vv cannot show it.

git uses the "upstream branch" to decide where to pull from and where to push to (more or less; it's configurable).

git-svn, in contrast, simply goes back in the history of the local branch to the latest commit that came from SVN (the latest commit with a "git-svn-id"). That commit will also name the SVN branch (i.e. path in the SVN repo) that it was created from (it's part of the string after "git-svn-id"). git-svn will then use that SVN branch.

This is described in the git-svn manpage:

Note the following rule: git svn dcommit will attempt to commit on top of the SVN commit named in

git log --grep=^git-svn-id: --first-parent -1

It's not noted in the manual, but I believe that git svn rebase uses a similar rule.



来源:https://stackoverflow.com/questions/20975754/which-remote-branches-are-my-local-git-svn-branches-bound-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!