git 推送至svn使用记录

一,配置svn 保存明文密码

这样,使用git推的时候,就不会每次询问密码了。
With recent versions of Subversion (~ 1.8) you can configure password caching via $HOME/.subversion/servers:

1
2
3
[global]
store-passwords = yes
store-plaintext-passwords = yes

But depending on your system this may be not enough. If it is not, make sure that $HOME/.subversion/config contains:

1
2
[auth]
password-stores =

Which means that the variable password-stores is explicitly set to the empty string (background is that svn now contains support for some key-agent tools - and the interfacing to the default configured ones may be fragile - resulting in silent ignoring of the above options and non-caching behaviour).

When using svn for the first time, the hierachy $HOME/.subversion is created after the first svn operation - e.g. when doing the first checkout. Subversion creates then the mentioned files and fills them with the most important options - commented out, including some documentation.

Thus, it also makes sense to move an old $HOME/.subversion directory away to have a well-defined starting point.

Another pitfall are permissions - i.e. files which are not readable under $HOME/.subversion - but this should not often be the problem, because when svn creates them, it takes care of the right permissions (e.g. the auth directory is only readable by the user then, not by the group/all, independent of the configured umask).

摘自: http://stackoverflow.com/questions/2599281/cant-make-svn-store-password-even-though-the-configuration-is-set-to-allow-it

看了下, 修改过配置后,保存的密码是明文的,如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
┌─[sh4d0walker@HuangYe] - [~/.subversion/auth/svn.simple] - [Wed Jul 09, 02:46]
└─[$] <> cat 1902b28055f9b44a3128bef8bfcaf4fc
K 8
passtype
V 6
simple
K 8
password
V 8
pw123456
K 15
svn:realmstring
V 31
<svn://172.16.7.253:81> prj2014
K 8
username
V 6
abcdef
END

可以看到 ,这里有仓库地址, 用户名(abcdef) 和明文密码(pw123456)
K 和 V后面那个数字表示的是值的字符长度.

二, git 开始拉取svn仓库中的代码

git svn clone -s svn://172.16.7.253:81/prj2014/myprj/

注意最后面的/ 一定不能忘记了,不然没法clone. svn 就是这样,忍受下吧.

The -s is there to signify that my Subversion repository has a standard layout (trunk/, branches/, and tags/.) If your repository doesn’t have a standard layout, you can leave that off.
-s 参数表示使用的是svn标准命名方法,即 trunk,tags,branches,这个参数有时很重要,建议使用,命 令后面还可以加个文件夹名字作为clone后的目录

1
git svn fetch

可能碰到只想从某个版本开始进行fetch,那么请需要 –r 参数。 例如:

1
$ git svn fetch -r 1342:HEAD

本地修改代码后提交
这个跟没用svn时一样,不提.

同步远程svn 服务器

1
git svn rebase

我个人的理解就是,这里相当于svn里的svn up 命令.

Before committing back to Subversion, you will want to update to apply any new changes in the repository to your local Git repo.

This will download all new changesets from Subversion, apply them to the last checkout from Subversion, and then re-apply your local changes on top of that.

推送到远程svn服务器

When you’re ready to commit back to Subversion, execute:

1
git svn dcommit

日常修改和提交
与git的工作流程完全一样

为了方便合并,减少不必要的麻烦,最好保持主分支master不变,在一个新的分支进行日常工作
切回master从SVN获取最新代码

1
2
$ git checkout master
$ git svn rebase

master同步后,与工作分支合并

1
2
$ git checkout work
$ git rebase master     ## 手工解决可能的冲突

最后说下, git-svn初始化, 这个应该用得少。

1
git svn init SVNREMOTEURL

参考:
http://hufeng825.github.io/2013/09/03/git9/
http://viget.com/extend/effectively-using-git-with-subversion

扩展阅读:
git 高级技巧: http://viget.com/extend/a-gaggle-of-git-tips

更多
No Responses Post a comment

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS