Gitee添加项目(代码提交到码云)

本文详细介绍了如何通过Git进行本地项目与码云仓库的交互,包括初始化Git仓库、添加远程仓库、提交代码、推送更新等步骤。在遇到远程仓库已有文件时,需先执行git pull再push,确保代码同步。该教程适合初学者掌握Git基本操作。
摘要由CSDN通过智能技术生成

1.码云先创建项目(或者叫仓库)

正常创建即可

在这里插入图片描述

2.在本地项目对应的文件夹内操作

在这里插入图片描述

3.进入目录

鼠标右键,选择git bash here,输入 git init

在这里插入图片描述

4.复制刚刚在码云新建的项目里,框框里的路径

在这里插入图片描述

5.继续操作git

输入git remote add origin  你刚刚在码云复制的那行路径

在这里插入图片描述

6.使用git add . (. 表示所有的)或者 git add + 文件名

这步操作是将文件保存到暂存区

7.使用git commit -m ‘新添加的文件内容描述’

这是提交代码,和提交的代码的描述信息,提交到本地仓库

例: git commit -m '初始化项目'

8.使用git push origin master

将本地仓库中的最新信息push到远程仓库

期间提示输入用户名密码正常输入(Gitee的用户名密码)即可

9.结束,刷新新创建仓库的页面即可

10可能出现的错误

error: failed to push some refs to 'xxxxx'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

说明在push之前,远程库里已经有文件存在了,应该先pull一下,把已存在的文件全拿下来

git pull origin master

然后再push即可

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值