查看: 106|回覆: 0

将本地项目添加到gitee仓库的操作流程:

[複製鏈接]

2

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2008-5-24
發表於 2020-10-26 22:13:00 | 顯示全部樓層 |閲讀模式

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

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部