git-svn 中的一些常用操作

Tracking and contributing to the trunk of a Subversion-managed project (ignoring tags and branches):

       # Clone a repo (like git clone):
               git svn clone http://svn.example.com/project/trunk
       # Enter the newly cloned directory:
               cd trunk
       # You should be on master branch, double-check with 'git branch'
               git branch
       # Do some work and commit locally to Git:
               git commit ...
       # Something is committed to SVN, rebase your local changes against the
       # latest changes in SVN:
               git svn rebase
       # Now commit your changes (that were committed previously using Git) to SVN,
       # as well as automatically updating your working HEAD:
               git svn dcommit
       # Append svn:ignore settings to the default Git exclude file:
               git svn show-ignore >> .git/info/exclude
   Tracking and contributing to an entire Subversion-managed project (complete with a trunk, tags and branches):

       # Clone a repo with standard SVN directory layout (like git clone):
               git svn clone http://svn.example.com/project --stdlayout --prefix svn/
       # Or, if the repo uses a non-standard directory layout:
               git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/
       # View all branches and tags you have cloned:
               git branch -r
       # Create a new branch in SVN
               git svn branch waldo
       # Reset your master to trunk (or any other branch, replacing 'trunk'
       # with the appropriate name):
               git reset --hard svn/trunk
       # You may only dcommit to one branch/tag/trunk at a time.  The usage
       # of dcommit/rebase/show-ignore should be the same as above.
The initial git svn clone can be quite time-consuming (especially for large Subversion repositories). If multiple people (or one person with multiple machines) want to use git svn to interact with the same
   Subversion repository, you can do the initial git svn clone to a repository on a server and have each person clone that repository with git clone:

       # Do the initial import on a server
               ssh server "cd /pub && git svn clone http://svn.example.com/project [options...]"
       # 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
       # --stdlayout/-T/-b/-t/--prefix options as were used on server)
               git svn init http://svn.example.com/project [options...]
       # Pull the latest changes from Subversion
               git svn rebase
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值