Skip to content

Instantly share code, notes, and snippets.

@flaneur2020
Last active October 13, 2015 05:37
Show Gist options
  • Save flaneur2020/4147427 to your computer and use it in GitHub Desktop.
Save flaneur2020/4147427 to your computer and use it in GitHub Desktop.
SucksVersioN

SucksVersioN

svn提供了比git更为精细的权限控制,按照目录为单位。

  • checkout: svn co http://svn.miaomiao.com/svn/trunk -r HEAD
  • 创建自己的分支目录:svn mkdir http://svn.foo.com/svn/branches/fleuria
  • 创建特性分支:svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1
  • 切换分支:svn switch http://svn.foo.com/svn/branches/fleuria/issue1
  • 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: svn commit -m 'commit message' file1.c file2.c
  • 撤销当前的所有更改: svn revert -R .
  • merge需要先得到revision的范围: svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000
  • 获取分支的第一个revision: svn log -v --stop-on-copy
  • 当前修改: svn st -q
  • revert当前的所有修改: svn revert `svn st -q`
  • merge合并过trunk的分支时记得加上: --reintergrate
  • 查看某文件在其它分支或者某revision时的样子: svn cat http://svn.foo.com/svn/branches/fleuria/readme.md
  • 切分支时敲完整的分支地址名无比蛋疼: svn sw ^/trunk, svn sw ^/branches/fleuria/feature_branch1

Troubleshoots:

Working copy locked

cd .svn; rm lock

svn: E160013: '/svn/shire/!svn/bc/135926/branches/miaomia/meow' path not found

先检查下哪里拼错了。

svn: Failed to add directory 'waymeet': an unversioned directory of the same name already exists

svn switch时如有遇到如此提示,删掉这个waymeet文件重新执行原先的svn switch

svn st -q 时列出来一坨S状态的文件

如果svn switch被中断会出现这种情况。

恢复: svn info bad_file 查看某个S状态的文件所在的分支,然后svn switch到这个分支。

git-svn

git svn clone非常慢,如果某项目有个只读的git镜像,clone它要比clone svn仓库快的多,随后再修改下.git/config即可。

git clone http://[email protected]/repo-ro.git repo
cd repo
git remote rm origin
git svn init http://svn.repo.com/repo/trunk -R svn
cp .git/refs/heads/master .git/refs/remotes/git-svn
git svn fetch

远程分支:

git config --add svn-remote.newbranch.url https://svn/path_to_newbranch/
git config --add svn-remote.newbranch.fetch :refs/remotes/newbranch
git svn fetch newbranch [-r<rev>]
git checkout -b local-newbranch -t newbranch
git svn rebase newbranch
  • Q: 初始化git-svn最简单的方法?

    A: 到开发机上拷贝一份同事的仓库然后改改.git/config什么的...

  • Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226

    A: rm -rf .git/svn/.caches

  • Q: Multiple branch paths defined for Subversion repository. You must specify where you want to create the branch with the --destination argument.

    A: 修改.git/config,添加: branches = branches/liyazhou/*:refs/remotes/*[svn-remote "svn"]下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment