如何把本地文件上传到码云(同github)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010221508/article/details/87818151

1.在码云上创建一个仓库

在这里插入图片描述
在这里插入图片描述
2. 复制一下仓库的地址
在这里插入图片描述
3.进入到要上传的本地文件的目录下
在这里插入图片描述
4.在当前目录下打开git命令窗(前提必须安装了git工具)
在这里插入图片描述
5.执行git命令

 git init
 git add .
 git commit -m "inital"
 git remote add origin https://gitee.com/ABC_MA_NONG/Utils.git  (这个是复制的远
 程仓库的地址)
 git pull origin master 
 git push -u origin master

在这里插入图片描述
此时可以看到推送到远程地址被拒绝了,
To https://gitee.com/ABC_MA_NONG/Utils.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://gitee.com/ABC_MA_NONG/Utils.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.
是因为在创建仓库的时候,顺便创建了README.md文件,导致产生了冲突,所以push不上去
在执行下面的git命令就可以了

		git pull --rebase origin master
		git push -u origin master

如图
在这里插入图片描述
git pull --rebase origin master 的意思是:
拉取远程的文件把本地的覆盖,再上传

可以看到文件已经推送到了远程服务器了
在这里插入图片描述
此过程适用于github,完毕

猜你喜欢

转载自blog.csdn.net/u010221508/article/details/87818151
今日推荐