当前位置:首页 > linux教程 > 列表

git 推送至svn使用步骤详解

发布:smiling 来源: PHP粉丝网  添加日期:2015-04-29 13:50:56 浏览: 评论:0 

svn是同步版本控制工具而git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项了,下面我们就一起来git 推送至svn使用方法,希望下文能够帮助到大家.

一,配置svn 保存明文密码

这样,使用git推的时候,就不会每次询问密码了.

  1. With recent versions of Subversion (~ 1.8) you can configure password caching via $HOME/.subversion/servers: 
  2.  
  3. [global] 
  4. store-passwords = yes 
  5. store-plaintext-passwords = yes 
  6. But depending on your system this may be not enough. If it is not, make sure that $HOME/.subversion/config contains: 
  7.  
  8. [auth] 
  9. password-stores = 
  10. 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).  --phpfensi.com 
  11. 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. 
  12. Thus, it also makes sense to move an old $HOME/.subversion directory away to have a well-defined starting point. 
  13. 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). 

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

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

git svn fetch

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

$ git svn fetch -r 1342:HEAD

本地修改代码后提交,这个跟没用svn时一样,不提.同步远程svn 服务器:git svn rebase 我个人的理解就是,这里相当于svn里的svn up 命令.

  1. Before committing back to Subversion, you will want to update to apply any new changes in the repository to your local Git repo. 
  2. 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:

git svn dcommit

日常修改和提交,与git的工作流程完全一样,为了方便合并,减少不必要的麻烦,最好保持主分支master不变,在一个新的分支进行日常工作.

切回master从SVN获取最新代码:

  1. $ git checkout master 
  2. $ git svn rebase 

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

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

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

git svn init SVNREMOTEURL.

Tags: git推送 svn使用步骤

分享到: