一、 Import project from github to gitee
目的: 当GitHub无法访问时,能够访问国内仓库国内仓库gitee.com 。
Solution:
Login In https://gitee.com/, use '"Import Respository"' to import project from github to gitee.
List all project form GitHub. Then choose to import project.
Wait for a minute, import successfully.
二、Sysnchronize project code from GitHub to gitee
Scenario:When Github android-art-res.git code updated,how to sysnchronize code to gitee ?
Solution 1: Use gitee fresh button.
Sample:
https://gitee.com/YingVickyCao/android-art-res.git
https://gitee.com/YingVickyCao/android-art-res.git
In gitee project page,Click 'fresh' button, force sysnchronizing from github project.
Wait for a minute, sysnchronize successfully.
Solution 2: Use git push command
Sample:
git@gitee.com:YingVickyCao/android-about-demos.git
git@github.com:YingVickyCao/android-about-demos.git
Use git push both command
# In terminal,cd project dir.
# 添加一个名为 both 的远端
$git remote add both git@gitee.com:YingVickyCao/android-about-demos.git
# 为其添加 push 到 gitee.com 的 SSH 地址
$git remote set-url --add --push both git@gitee.com:YingVickyCao/android-about-demos.git
# 为其添加 push 到 GitHub 的 SSH 地址
$git remote set-url --add --push both git@github.com:YingVickyCao/android-about-demos.git
#查看当前远端仓库
$git remote -v
both git@gitee.com:YingVickyCao/android-about-demos.git (fetch)
both git@gitee.com:YingVickyCao/android-about-demos.git (push)
both git@github.com:YingVickyCao/android-about-demos.git (push)
origin git@github.com:YingVickyCao/android-about-demos.git (fetch)
origin git@github.com:YingVickyCao/android-about-demos.git (push)
In project .git/config file, we can "both" add successfully.
# modify code
$ git add .
$ git commit -m "test code"
$ git push both
Warning: Permanently added the RSA host key for IP address '192.30.255.112' to the list of known hosts.
What this Warning means?
警告:为IP地址192.30.255.112的主机(RSA连接的)持久添加到hosts文件中
192.30.255.112 是什么地址?
http://www.ip.cn/index.php?
Add IP address '192.30.255.112' to the list of known '/etc/hosts'
- backup /etc/hosts first.
- Copy /etc/hosts, and then add it.
- Overwrite /etc/hosts.
PS:
- 使用git push origin both,可以push到origin的多个url地址.
- 使用git pull时,只能拉取origin里的一个url地址(即fetch-url,如上图),这个fetch-url默认为添加的到origin的第一个地址。
如果更改,只需要更改config文件里,那三个url的顺序即可,fetch-url会直接对应排行第一的那个utl连接。
Reference
- http://blog.csdn.net/shengzhu1/article/details/53493722
- https://www.cnblogs.com/xiangyangzhu/p/5316041.html
- http://www.ip.cn/index.php?ip=192.30.255.112
- http://blog.csdn.net/s0228g0228/article/details/45368155
TBD
No.
结束语
感谢Reference
中各位作者的无私贡献.
欢迎大家留言、指点、交流。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。