Archive

Posts Tagged ‘git-svn’

Google Code 与 Github同步

September 28th, 2010 No comments

由于Golang中文翻译项目同时采用Google Code和Github两种方式管理,这里简单的记录一下流程.

1. 从Google Code代码库里面取得历史数据
border@colinux:~/work/golang-china$ git svn clone https://golang-china.googlecode.com/svn/trunk .
border@colinux:~/work/golang-china$ git branch -a
* master
remotes/git-svn

2. 增加Github源
border@colinux:~/work/golang-china$ git remote add github git@github.com:border/golang-china.git
同步github
border@colinux:~/work/golang-china$ git fetch github
remote: Counting objects: 37, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 30 (delta 14), reused 13 (delta 3)
Unpacking objects: 100% (30/30), done.
From github.com:border/golang-china
* [new branch] master -> github/master

border@colinux:~/work/golang-china$ git branch -a
* master
remotes/git-svn
remotes/github/master

border@colinux:~/work/golang-china$ git branch -r
git-svn
github/master

给github的源创建一个单独的分支
border@colinux:~/work/golang-china$ git checkout -b github github/master
Branch github set up to track remote branch master from github.
Switched to a new branch ‘github’

border@colinux:~/work/golang-china$ git branch
* github
master

border@colinux:~/work/golang-china$ git branch -a
* github
master
remotes/git-svn
remotes/github/master

border@colinux:~/work/golang-china$ git status
# On branch master
nothing to commit (working directory clean)

border@colinux:~/work/golang-china$ git branch
github
* master

3. 在master分支基础之上创建一个自己的分支用于与GoogleCode和Github进行合并
border@colinux:~/work/golang-china$ git checkout -b border
Switched to a new branch ‘border’

查看当前多有得分支
border@colinux:~/work/golang-china$ git branch -a
* border
github
master
remotes/git-svn
remotes/github/master

现在可以在border分支上与github合并
border@colinux:~/work/golang-china$ git merger github

解决一些冲突后,然后border分支目前是最新的版本。

接下来分别切换到master和github分支,并与border进行合并。

border@colinux:~/work/golang-china$ git checkout master
border@colinux:~/work/golang-china$ git merger border
在master分支下,提交相关的版本
border@colinux:~/work/golang-china$ git svn dcommit // 上传本地的代码到Google Code

border@colinux:~/work/golang-china$ git checkout github
border@colinux:~/work/golang-china$ git merger border
border@colinux:~/work/golang-china$ git push

git svn rebase // 本地与Goolge Code 代码同步
git svn dcommit // 上传本地的代码到Google Code

1. git-remote(1) Manual Page http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
2. Google Code 与 Github代码同步 http://wifihack.net/blog/2010/01/google-code-svn-and-github-sync/
3. 混合使用Git SVN 和Git http://zoomquiet.org/res/scrapbook/ZqFLOSS/data/20081212152336/index.html

Categories: golang, Tech.Notes Tags: , , ,

Git-svn workflow

April 3rd, 2009 No comments

本文参考: http://notes.jimlindley.com/2008/3/25/git-svn-that-works-for-me
作者: Jim Lindley

The canonical git-svn workflow that I’ve seen goes like this:
标准的git-svn工作流程参考这里:

[code lang="C"]
git svn clone
git checkout -b
...hack...hack...

git commit -a
git checkout master
git merge #NOTE: no need for --squash anymore
git svn rebase
git svn dcommit -e # -e will let you enter a commit message for SVN

[/code]

I’ve had more luck with the following workflow, when integrating changes via SVN from other team members:
我从团队的其他成员学到了更好的工作流程:

[code lang="C"]
# initial setup
git svn clone

# 99% of daily workflow
git checkout -b
...hack...hack...
git commit -a

# switch back to master, then rebase against
# any revisions in the svn repo
git checkout master
git svn rebase

# now that master is current with svn,
# sync working branch to local master
git checkout # These two are the added steps
git rebase master # which help prevent conflicts

# final upstream commit after rebasing
git checkout master
git svn rebase # one last check for new svn check ins
git merge
git svn dcommit -e

[/code]

The extra rebase step seems to do a better job of integrating your patches into the tree. Merge should do the same thing, if I’m reading the man pages right, but splitting the steps is more idiot proof (me-proof) this way.

It also keeps the master local branch from getting messy dealing with conflicts. Instead conflict is kept in the side working branch.

上面虽然很罗嗦但是做的好处在于,我们把所有的工作和从svn代码的合并都放在本地的分支上进行。这样就能保证本地主干与svn服务器进行同步,并且在本地主干没有任何修改。

更多有关git, git-svn,  git-reset 的文章:
1. git-svn workflow
2. An introduction to git-svn for Subversion/SVK users and deserters
3. Git reset in depth

2009.4.3
Bian Jiang
–EOF–

Categories: Tech.Notes Tags: , , ,