一、 Import project from github to gitee

场景:备份GitHub代码仓库到国内仓库gitee.com

目的: 当GitHub无法访问时,能够访问国内仓库国内仓库gitee.com

Solution:

Login In https://gitee.com/, use '"Import Respository"' to import project from github to gitee.

https Respository

List all project form GitHub. Then choose to import project.
https Respository

Wait for a minute, import successfully.
https Respository

二、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.

https Respository

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.
.git/config

# 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.

git push both Warning

What this Warning means?

警告:为IP地址192.30.255.112的主机(RSA连接的)持久添加到hosts文件中

192.30.255.112 是什么地址?
http://www.ip.cn/index.php?
check ip

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.

IP address to hosts

  • Overwrite /etc/hosts.

PS:

  • 使用git push origin both,可以push到origin的多个url地址.
  • 使用git pull时,只能拉取origin里的一个url地址(即fetch-url,如上图),这个fetch-url默认为添加的到origin的第一个地址。
    Git push pull error

如果更改,只需要更改config文件里,那三个url的顺序即可,fetch-url会直接对应排行第一的那个utl连接。

Reference

TBD

No.

结束语

感谢Reference中各位作者的无私贡献.

欢迎大家留言、指点、交流。


已注销
2 声望0 粉丝

Make a little progress every day.