將本地項目添加到gitee倉庫的操作流程:


將本地項目添加到gitee倉庫的操作流程:

  1. 碼雲上創建一個項目,例如 fighting

  2. 本地創建一個文件夾D:/Java/fighting,然后鼠標右擊選擇git bash here

  3. 使用 git init 命令,初始化一個git本地倉庫(項目),會在本地創建一個 .git 的文件夾

  4. 使用git remote add origin fighting的git克隆地址 //添加遠程倉庫 // 示例:git remote add origin https://gitee.com/xxxx/fighting.git// 示例:git remote add origin https://gitee.com/cheng-huanlong/chl.git

  5. 使用 git pull origin master 命令,將碼雲上的倉庫pull到本地

  6. 將要上傳的文件,添加到剛剛創建的文件夾fighting里

  7. 使用git add . 或者 git add + 文件名 (將文件保存到緩存區)

  8. 使用git commit -m ‘描述新添加的文件內容’ (就是提交代碼的注釋) (文件保存到本地倉庫)

  9. 使用git push origin master,將本地倉庫推送到遠程倉庫

完成!

git push遇到錯誤: [rejected]master -> master (non-fast-forward)的解決方法

執行git push只之后報如下錯誤:

Username for 'https://gitee.com': **@**.com
fatal: unable to get credential storage lock: File exists
To https://gitee.com/**/**.git
! [rejected]       master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/**/**.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解決方法:

git pull origin master --allow-unrelated-histories //把遠程倉庫和本地同步,消除差異

git add .

git commit -m '***'

git push origin master


免責聲明!

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



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