window端GitHub托管代码

来源:互联网 发布:火山软件开发平台 编辑:程序博客网 时间:2024/06/06 01:51
一些前期配置见博客点击打开链接
1、下载GitHub的bash和Windows desk版本,在用户目录下生成自己的公钥.pub
cd ~
ssh-keygen -t rsa 
一直enter
2、把用户公钥粘贴GitHub网站的ssh key那,下次免密上传
https://www.zhihu.com/question/21402411
3
第一次进入时:echo "# f2fsCode" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:xixiss/f2fsCode.git
git push -u origin master

以后每次提交:
git add 文件名
git commit -m "修改描述"
git push
4、git的客户端和网页端都能查看最近的更改。客户端还能回滚

使用遇到的问题
$ git push
To github.com:xixiss/f2fsCode.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:xixiss/f2fsCode.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
这是因为local版本和远端版本不一致造成的(不一致的原因是再客户端和bash两个地方同时更改,造成了版本不一致),需要同过git pull 操作,拉取远程代码,使得版本同步,才能继续push


所以在协同操作时,每次操作要确保自己写的local版本与remote版本一致:写之前先pull一次!!!!
这样,每次编辑之前,都是最新版本,协同操作也变成了版本的迭代,就像一个人在一直提交一样(一个人不用pull的原因是,每次他写好的代码,push上去之后,没有别人去改,于是本地和远端代码一直一致,因此不用pull)