git-svn:如何在dcommit上更改svn用户名?

5

我使用 git svn clone 将一个 SVN 仓库克隆到了一个 git 仓库。那时,我在该站点没有用户名,因此没有使用 --username 选项来执行 clone。现在我可以用我的新用户名提交到 SVN 仓库,我想添加该用户名。如果没有它,dcommit 将无法成功:

% LANG=C git svn dcommit 
Committing to <THE URL> ...
RA layer request failed: Server sent unexpected return value (405 Method Not Allowed) in response to MKACTIVITY request for '/svn/!svn/act/0ceca4c5-f7b4-4432-94be-0485559a6040' at /usr/lib/git-core/git-svn line 945.

有没有办法告诉git一个新的用户名? Git-svn手册似乎没有帮助:只有在initbranch时才允许添加用户名。我不知道git在内部如何使用SVN,但我猜应该有一种方法可以在之后添加用户名。
请注意,我正在使用通过http的SVN。
3个回答

1
你可以在 dcommit 命令中指定用户名,例如:
git svn dcommit --username=isapir

0
请注意,如果您指定了用户名,则在 Git 2.16.x/2.17(Q1 2018)之前,您将无法 dcommit 合并提交。
这是因为 "git svn dcommit" 没有考虑到带有 username@(通常用于推送)的 svn+ssh:// URL 是指向同一个 SVN 库而没有 username@,并且当设置 svn.pushmergeinfo 选项时会失败。

查看提交8aaed89(2017年9月15日),作者为Jason Merrill (jwmerrill
(由Jason Merrill -- jwmerrill --于2017年9月17日合并自提交8aaed89

git-svn: fix svn.pushmergeinfo handling of svn+ssh usernames.

Previously, svn dcommit of a merge with svn.pushmergeinfo set would get error messages like

merge parent <X> for <Y> is on branch svn+ssh://gcc.gnu.org/svn/gcc/trunk, 
which is not under the git-svn root svn+ssh://jason@gcc.gnu.org/svn/gcc!"

So, let's call remove_username (as we do for svn info) before comparing rooturl to branchurl.


0
我认为你可以使用这个过程(来自git svn手册)来创建现有svn存储库的克隆,但是更改git svn init步骤,以便指定用户名。然后,你的新git-svn存储库将具有一个用户名。
# Clone locally - make sure the refs/remotes/ space matches the server

    mkdir project
    cd project
    git init
    git remote add origin server:/pub/project
    git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
    git fetch
# Prevent fetch/pull from remote git server in the future,
# we only want to use git svn for future updates
    git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched

    git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
    git svn init --username my_new_name http://svn.example.com/project
# Pull the latest changes from Subversion
    git svn rebase

除此之外,我使用了http://theadmin.org/articles/git-svn-switch-to-a-different-a-svn-url/来在设置新用户名后更改URL。 - evnu
我该如何更改用户名?在我的本地git提交中,我得到了我的用户名和电子邮件ID。但是当我推送到svn时,我得到了设置git svn的那个人的用户名。我尝试运行“git svn --username <myusername>”,但我看到消息说“GIT_SVN_ID可能在环境中设置……(一长串消息)”。 - CODError

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接