在vscode中使用git命令 將代碼托管到碼雲


在vscode中使用git命令 將代碼托管到碼雲

1、下載git【官網:https://git-scm.com/download/win】和安裝git 工具,默認安裝即可

 

 

 安裝成功后的桌面圖片如下:

 

 

 

2、git一些常用命令

1 git --version    //查看git版本
2 git init
3 git status
4 git add .
5 git commit -m "init my project"

 

3、登錄碼雲 【碼雲官網:https://gitee.com/】,右上角圖標下找到 “設置”---安全設置---ssh公鑰 ,點開“如何添加公鑰”

  根據教程,在git bash中輸入以下命令

你可以按如下命令來生成 sshkey:

1 ssh-keygen -t rsa -C "xxxxx@xxxxx.com" 
2 # Generating public/private rsa key pair...

按照提示完成三次回車,即可生成 ssh key。通過查看 ~/.ssh/id_rsa.pub 文件內容,獲取到你的 public key

1 cat ~/.ssh/id_rsa.pub
2 # ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....

然后將查看到的公鑰,復制到 添加公鑰部分即可

只有把電腦添加到公鑰中才能上傳代碼

 

4、創建空倉庫,輸入名稱后 ,直接點擊創建即可, 根據提示, 在cmd 黑窗口,輸入以下,命令

1 //用戶名和郵箱都要定義自己,且要記在小本本上
2 git config --global user.name "xxxxxx"
3 git config --global user.email "2xxx8xxx8@qq.com"

 

5、然后根據已有項目進行如下操作:

1 cd existing_git_repo #----進入項目根目錄
2 git remote add origin https://gitee.com/sxdevloper/webpack-vue-project.git #跟遠程倉庫進行連接【關聯遠程倉庫】
3 git push -u origin master #---------將項目添加到倉庫中

 

6、推送提示錯誤,https://blog.csdn.net/showgea/article/details/81031668?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase
解決辦法:清除本地的gitee用戶名和密碼

 

git config --system --unset credential.helper

 

 

 

 

ps:也可參考以下鏈接

【1、使用碼雲托管代碼 (轉載自:https://www.cnblogs.com/yucongblog/p/9763902.html)

2、git 安裝與配置(轉載自:https://www.runoob.com/git/git-install-setup.html

轉載自:https://www.cnblogs.com/NyanKoSenSei/p/11570452.html
轉載自:https://blog.csdn.net/zhen921/article/details/87905689?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase)】


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM