将本地项目添加到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