svn 项目转移到 git 码云

参考:http://www.csdn.net/article/a/2017-05-25/15928190

svn:自己搭建的

git:码云

工具:git-bash  (unix shell)

命令顺序

安装好git工具后,创建一个文件夹test,第一次:鼠标右键--Git  Bash Here   进入命令行

1>$  git init   初始化文件夹为git库

2>$  git svn clone svn://此处为ip地址/项目路径     举例:git svn clone svn://127.0.0.1/project/trunk/test-admin

输入后,

第一次:需要输入本机windows系统的登录密码

第二次:输入svn帐号

第三次:输入svn密码

根据项目大小会把所有提交文件都进行下载,过程略久

下载好后,在码云上建立项目 test-admin   使用Readme文件初始化这个项目(这个选项要去掉)

创建好后,点项目名,进入项目中,“克隆/下载” 可得到下载地址:https://git.oschina.net/xxxxx/test-admin.git

在这里要注意,在test目录的下一级 test-admin操作,第二次:鼠标右键--Bash Here(不然传到git服务器里面的只会是git子项目,无法直接显示、提交代码)

test(在test文件夹内操作:是第一次)

——.git

——test-admin (在test-admin内操作:是第二次

——————   .git

—————— pom.xml  

——————test-admin-web

——————test-admin-core

(或者使用  git log   检测能否看到,项目之前的提交记录,以此来判断 操作是否正确)


3>$  git remote add origin https://git.oschina.net/xxxxx/test-admin.git  添加远端库地址 设定名称为origin

添加成功没有提示的,所以看下是否成功

$ git remote -v
origin  https://git.oschina.net/xxxxx/test-admin.git (fetch)
origin  https://git.oschina.net/xxxxx/test-admin.git (push)
是成功的!继续

此处如果添加错误:使用命令  git remote remove origin   即可删除名为origin的远端库


git pull

然后遇到报错:

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


git push

报错:

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

个人猜测:远端库是刚初始化的,还没有建立分支

4>$ git push -u origin master   代码提交成功 搞定了

此时再用 git push   或者  git pull  命令都不会报错了


如果前创建项目时:默认勾选了“用Readme文件初始化这个项目”,会报错

To https://git.oschina.net/zx1323/test.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://git.oschina.net/zx1323/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


4>$  git pull --rebase origin master  获取远端分支,合并

5>$  git push origin master  推送到远端 

收工!

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值