开始用gitbucket保存项目啦。
心得:
1.初始化:在项目工程文件夹右键Git Bash Here,在该文件夹没有.git文件夹的情况下输入【git init】,把该文件夹变成git仓库。
2.关联gitbucket:复制gitbucket上的仓库简介里的仓库地址(右键点复制,别ctrl+c),然后在命令里输入【git remote add origin 仓库地址】。
3.把文件添加到暂存区:继续输入【git add -A】。
4.继续输入【git commit –m“注释”】 提交文件 –m 后面的是注释。意思为 : 把暂存区的文件提交到本地仓库
5.继续输入【git push –u origin master】(第一次要用-u 以后不需要) , 把本地仓库推送到远程仓库 , 即推送到Bitbucket创建的仓库 , 弹出窗口提示输入Bitbucket密码 , 按Ok确认推送
6.更新文件:小伙伴假如需要修改文件或者添加文件 , 那么就重复「git add –A」提交文件到暂存区→ 「git commit –m“注释”」把暂存区的文件提交到本地仓库→「git push」推送到远程仓库 , 即可
7.git push origin master 报错的解决方法
提示:
[root@linux1 php]# git push -u origin master To git@github.com:kangvcar/Results-Systems--PHP.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:kangvcar/Results-Systems--PHP.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 merge the remote changes (e.g., hint: 'git pull') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原因是gitbucket上的readme.md没删
解决办法:
我们只需加上 --rebase 参数然后再重新 push 一次即可
[root@linux1 qimo]# git pull --rebase origin master
[root@linux1 qimo]# git push -u origin master
7.github私人仓库添加成员(参考来源)
参考资料:
git图文教程:http://blog.jobbole.com/78960/
git明了初始教程:https://www.jianshu.com/p/08b7048ec925
git错误提示修复:https://www.jianshu.com/p/681a879745e4