背景

已有阿里云效的代码库,想迁移gitee却迁移不了,只能把代码先拉取下来,然后重新建库,配置过后,采用同步推送的方式,同步两个库的代码。

步骤一 新建名称相同的库 

在gitee上新建库

 

在阿里云效上新建库

 

步骤二 配置本地仓库

1. 初始化本地仓库 

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent
$ git init
Initialized empty Git repository in E:/mango-upc/upc-single/mango-upc-parent/.gi
t/

2. 修改.git文件夹的config文件

 

filemode = false ==> filemode = true

 3. 添加两个远程仓库

 

 

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git remote add gitee git@gitee.com:chenxin04187/mango-upc-parent.git

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git remote add codeup git@codeup.aliyun.com:62805d210065edd3d51a8664/mango-upc/upc-single/mango-upc-parent.git

4. 查看已添加的远程仓库

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git remote -v
codeup  git@codeup.aliyun.com:62805d210065edd3d51a8664/mango-upc/upc-single/mang
o-upc-parent.git (fetch)
codeup  git@codeup.aliyun.com:62805d210065edd3d51a8664/mango-upc/upc-single/mang
o-upc-parent.git (push)
gitee   git@gitee.com:chenxin04187/mango-upc-parent.git (fetch)
gitee   git@gitee.com:chenxin04187/mango-upc-parent.git (push)

这样就说明已经添加成功了。

步骤三 配置公钥

1. 输入如下命令设置公钥,邮箱地址是gitee和阿里云效绑定的邮箱(两者是相同的)

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ ssh-keygen -t ed25519 -C "xxx@hotmail.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_ed25519
Your public key has been saved in /c/Users/Administrator/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:6N5mUtL0SIJYhcUEbbfTNP1JmYVgKZb/7q0ANkloSYw kty.chan@hotmail.com
The key's randomart image is:
+--[ED25519 256]--+
|    .O+o.  ooo =.|
|    o E.oo*.o =  |
|   o o .+=.+ o . |
|  . . .o=.... o  |
|      .=S+=  .   |
|     .. +..o  .  |
|      .o    ..   |
|     ...o    ... |
|      .+.    .o..|
+----[SHA256]-----+

2. 在 C:\Users\Administrator\.ssh目录下找到.pub结尾的文件,打开后复制里面的内容,配置为gitee和阿里云效的公钥

2.1 配置gitee的个人公钥(一定要是个人公钥)

2.2  配置阿里云效的公钥

3. 验证密钥 (一定要验证)

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (180.76.198.77)' can't be established.
ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
Hi xxxx(@xxxx)! You've successfully authenticated, but GITEE.COM does not provide shell access.

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ ssh -T git@codeup.aliyun.com
The authenticity of host 'codeup.aliyun.com (118.31.165.50)' can't be established.
RSA key fingerprint is SHA256:yEGmgQNVrc3QAvDvoBrTCF2s07KwmmQ+AbWi9vSt/fE.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'codeup.aliyun.com' (RSA) to the list of known hosts.
Welcome to Codeup, xxxx@qq.com!

 验证完成后在C:\Users\Administrator\.ssh目录下会多一个known_hosts的文件,里面存放着已知的host

步骤四 推送代码

本次操作为同步推送已有仓库,所以是这样弄的:

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git add ./

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git commit -m "迁移工程"
[master (root-commit) a9340c9] 迁移工程
 3 files changed, 262 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 README.md
 create mode 100644 pom.xml

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git push --all gitee
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 2.79 KiB | 2.79 MiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To gitee.com:chenxin04187/mango-upc-parent.git
 * [new branch]      master -> master

Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
$ git push --all codeup
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 2.79 KiB | 2.79 MiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
To codeup.aliyun.com:62805d210065edd3d51a8664/mango-upc/upc-single/mango-upc-par
ent.git
 * [new branch]      master -> master

如下命令默认推送到当前分支,所以可以在开发完后,直接用这个命令推送即可
$ git push --all codeup
$ git push --all gitee
推送tag
$ git push --tags codeup
$ git push --tags gitee
 
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐