git仓库迁移
git不是给coding收了嘛,结果要迁移代码,惨!(李亮脸)
我原来使用git的情况很简单,就是本地提交到gitcafe,然后服务器从gitcafe pull代码,如下图
现在的问题有这些:
- 有些代码还没commit
- 有一次commit还没push并且已经不能push
- gitcafe的仓库要迁移到coding
- 以后push代码到coding
第3个问题gitcafe和coding提供了解决方法,只要注册个coding账号,然后在gitcafe绑定coding账号,再登录coding选择要迁移的库,点几下,coding上就有gitcafe的代码了。
剩下的问题就是:要怎样确定本地代码与coding代码的关系,以及以后如何只往coding库push代码
bing一下你就知道,老外还真有现成的解决方法
结合pro git 远程仓库的使用就可以搞定了
以下是我大概的操作步骤:
- coding下添加本地和web server的ssh key
- 本地未commit的代码贮藏起来,也可以commit
- 本地和web server添加新的remote: git remote add new-origin git@git.coding.net:xxx/yyy.git
- 本地和web server删掉旧的remote: git remote rm origin
- 本地和web server将新的remote重命名: git remote rename new-origin origin
- 本地和web server就都可以像以前一样使用了
总结一下之所以可以通过直接替换(add a – rm b –rename a)remote实现git server的迁移,而本地的代码不需要删除和重新拉取,是因为本地git仓库和git server上的git仓库是同样的标准(当然啦都是git),而不管代码存放在哪里(remote),都是可以识别的(我实在不知道该怎么说。。。)。