git+码云部署

1码云注册

2.git安装:

这里选择的是客户端安装版,地址:https://git-scm.com/download/win。 一直下一步即可,安装完成后,桌面右键如下:Git GUI Here(客户端) 和GIT Batch Here(终端)

3.本机生成公钥:

在Git终端依次输入:
  1、cd ~/.ssh,显示 bash: cd: /c/Users/lenovo/.ssh: No such file or directory则表示没有生成过公钥,如果不是则表示生成过公钥,可使用cat ~/.ssh/id_rsa.pub查看,也可在本地用户目录下的.ssh下查看。
  2、生成公钥,命令如下:ssh-keygen。
  3、查看公钥,命令如下:cat ~/.ssh/id_rsa.pub。

4.添加本机公钥至码云

5.码云新建仓库

6.配置本机git

6.1.设置本机git信息git config --global user.name "xxx" git config --global user.email "xxx"

6.2创建项目

mkdir huahua
cd huahua
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/xuyongw/huahua.git

6.3.提交代码git push origin master git pull origin master

参考地址 :https://blog.csdn.net/james_jr10/article/details/79902784

遇到的问题:

1。第一次账号密码输错,删除重输:git config --system --unset credential.helper

2.删除链接:

  1、git配置远程地址

  git remote add origin url ,其中url为远程仓库地址。

  2、git删除远程地址

  git remote rm origin

  查看远程仓库地址信息

  git remote -v 

3.push错误:

! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/xuyongw/huahua.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.

1.使用强制push的方法:

$ git push -u origin master -f

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

$ git pull origin master

$ git push -u origin master

3.若不想merge远程和本地修改,可以先创建新的分支:

$ git branch [name]

然后push

$ git push -u origin [name]

参考:https://blog.csdn.net/michael10001/article/details/51371715

每次pullpush都要输入账号密码,原因用了https方式,改为ssh即可。两种链接地址吗云仓库右上角可以找到,更改代码文中有。

猜你喜欢

转载自www.cnblogs.com/weilovehua/p/11873124.html