1、创建仓库

1.1、登录gitee,选择导航栏右侧的+号->新建仓库
1.2、给仓库起个名字
(如果不开源以上步骤就创建好一个仓库了,若开源,等创建好仓库后选择管理,再里面将仓库改为开源)

2、本地初始化仓库

2.1、在桌面建一个文件夹(任何地方都可),git bash
2.2、git init

3、上传步骤

3.1、git add .
3.2、git commit -m "提交"
3.3、git remote add origin git仓库地址 //连接远程仓库
3.4、git push -u origin master //把本地的仓库文件推送给远程仓库(这里可能会爆错)错误信息:Updates were rejected because the remote contains work that you do
这个时候不要慌,这个问题是因为本地新建仓库与远程仓库内容不一样导致的
直接接着输入
3.4、git pull origin master //把本地的仓库文件推送给远程仓库 (这里可能又会爆错)
错误信息:
fatal:refusing to merge unrelated histories
(这个错误是因为文件版本没有及时更新,分支具有不同的提交历史,是两个不同版本的分支,直接执行下面的语句)
3.5、git pull origin master --allow-unrelated-histories
错误信息:
Your local changes to the fllowing files would be overwritten by merge
(文件有冲突,没有更新,直接重来一遍)
3.6、git add .
3.7、git commit -am "tj"
3.8、git pull origin master --allow-unrelated-histories
3.9、git push -u origin master
以上就上传成功了。

命令代码如下:

0、git init
1、git add .
2、git commit -m "提交"
3、git remote add origin git仓库地址
4、git push -u origin master 
或 git pull origin master
5、git pull origin master --allow-unrelated-histories	
6、git add .
7、git commit  -am  "tj"
8、git pull origin master --allow-unrelated-histories
9、git push -u origin master

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐