上传代码到码云 简单方法以及坑

以下所有操作都在命令行进行

1 git 配置

git config --global user.name “用户名”

git config --global user.email “邮箱”

2 生成公钥私钥

	#ssh-keygen -t rsa -C "[email protected]"

一路Enter下去,将生成的公钥填在码云上

	#cat ~/.ssh/id_rsa.pub

3建立git仓库

在你的项目文件夹下执行git命令

git init

4 将项目文件添加到仓库中

git add .

5 将add的文件commit到仓库

git commit -m '备注'

6 将本地仓库关联到码云上

git remote add origin [email protected]:shiqingqing/test.git

7 上传码云前要先pull 下

git pull origin  master

8  最后一步 上传代码到码云仓库

git push -u origin master

执行完后到码云看你项目的代码

如出现错误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 push -u origin master -f  强制命令会覆盖别人分支,慎用

转发地址:https://blog.csdn.net/qq_36434647/article/details/78731931

https://blog.csdn.net/qq_28112913/article/details/79744324

GitHub地址:https://github.com/HuaDanJson

猜你喜欢

转载自blog.csdn.net/Jason_HD/article/details/82622222