当前位置:   article > 正文

git同步推送代码至gitee和阿里云效_可以将代码同时推向云效和gitee吗?

可以将代码同时推向云效和gitee吗?

背景

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

步骤一 新建名称相同的库 

gitee上新建库

 

在阿里云效上新建库

 

步骤二 配置本地仓库

1. 初始化本地仓库 

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

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

 

filemode = false ==> filemode = true

 3. 添加两个远程仓库

 

 

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

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

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

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

步骤三 配置公钥

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

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

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

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

2.2  配置阿里云效的公钥

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

  1. Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
  2. $ ssh -T git@gitee.com
  3. The authenticity of host 'gitee.com (180.76.198.77)' can't be established.
  4. ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
  5. This key is not known by any other names.
  6. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  7. Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
  8. Hi xxxx(@xxxx)! You've successfully authenticated, but GITEE.COM does not provide shell access.
  9. Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
  10. $ ssh -T git@codeup.aliyun.com
  11. The authenticity of host 'codeup.aliyun.com (118.31.165.50)' can't be established.
  12. RSA key fingerprint is SHA256:yEGmgQNVrc3QAvDvoBrTCF2s07KwmmQ+AbWi9vSt/fE.
  13. This key is not known by any other names.
  14. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  15. Warning: Permanently added 'codeup.aliyun.com' (RSA) to the list of known hosts.
  16. Welcome to Codeup, xxxx@qq.com!

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

步骤四 推送代码

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

  1. Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
  2. $ git add ./
  3. Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
  4. $ git commit -m "迁移工程"
  5. [master (root-commit) a9340c9] 迁移工程
  6. 3 files changed, 262 insertions(+)
  7. create mode 100644 .gitignore
  8. create mode 100644 README.md
  9. create mode 100644 pom.xml
  10. Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
  11. $ git push --all gitee
  12. Enumerating objects: 5, done.
  13. Counting objects: 100% (5/5), done.
  14. Delta compression using up to 16 threads
  15. Compressing objects: 100% (5/5), done.
  16. Writing objects: 100% (5/5), 2.79 KiB | 2.79 MiB/s, done.
  17. Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
  18. remote: Powered by GITEE.COM [GNK-6.4]
  19. To gitee.com:chenxin04187/mango-upc-parent.git
  20. * [new branch] master -> master
  21. Administrator@USER-20220820DL MINGW64 /e/mango-upc/upc-single/mango-upc-parent (master)
  22. $ git push --all codeup
  23. Enumerating objects: 5, done.
  24. Counting objects: 100% (5/5), done.
  25. Delta compression using up to 16 threads
  26. Compressing objects: 100% (5/5), done.
  27. Writing objects: 100% (5/5), 2.79 KiB | 2.79 MiB/s, done.
  28. Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
  29. To codeup.aliyun.com:62805d210065edd3d51a8664/mango-upc/upc-single/mango-upc-par
  30. ent.git
  31. * [new branch] master -> master

如下命令默认推送到当前分支,所以可以在开发完后,直接用这个命令推送即可
  1. $ git push --all codeup
  2. $ git push --all gitee
推送tag
  1. $ git push --tags codeup
  2. $ git push --tags gitee
 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/186042
推荐阅读
相关标签
  

闽ICP备14008679号