如何把本地文件上传到码云(同github)
程序员文章站
2022-04-17 18:46:03
...
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,完毕