玩弄Git实录

Git真是个烦人又让人无法放弃的东西……作为一个学了今天忘了昨天的渣渣,为了在多个场所(其实就家和公司而已装什么装)都能随时切入最新工作进度,必须写一个自己使用git的流水账……省得到时候每次都要重新找资料看怎么操作……

现在本地和远程仓库都已经建好了。先看看在神马地方。
查看远程仓库:git remote -v.名儿origin,地址https://gitee.com/LTLT666/firstproj.git
查看本地仓库:pwd.公司电脑的仓库是在/c/Users/user/firstproj 。家里的则是*。

公司电脑的仓库和gitee远程仓库是通过https协议传输的,可能是因为公司只开放http端口,只能用https而SSH不行,不过也没什么所谓。但是要先设置一下https代理。
不需要鉴权的全局代理设置:git config --global http.proxy 192.168.115.10:3333 #公司代理服务器的ip和端口
看看有木有成功:git config --get --global http.proxy.有显示出就成功咯。

设置好了开始干活了。开干之前先来一张图。这神图对理解git的工作方式灰常有效。
一图胜千言嘿嘿嘿。
一图胜千言嘿嘿嘿。

好的开始吧。现在丢了好些文件在/c/Users/user/firstproj 下。先git add 让它把文件放进仓库。然后git commit -m提交到仓库。

$ git add learnexam.py
$ git add MGT002R_Buyer_Quality_Metrics_10_Oct-2017.xlsx
$ git commit -m "add 2 files"   #-m后面的备注随便写

虽说有xlsx这种文件,还可以放其他各种文件,但是git的版本控制系统只能追踪到文本文件的每次修改,其他文件它知道你改了但不知道你改哪了。不过我只是当随时同步的仓库用用还是很好用的嘿嘿。

新文件都提交上去了,git status看看仓库状态。

$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 5 and 4 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean

这下有点方了,虽然工作目录干净没有东西需要提交,但是git pull宝宝还没完全搞明白。
试着推送到远程,果然也是一段痛心疾首的提示推送失败。

$ git push origin master
To https://gitee.com/LTLT666/firstproj.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/LTLT666/firstproj.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.

看这样我猜应该是远程master分支和本地master分支各有新的提交,出现冲突没法fast-forward。
别说了,撸起袖子把廖雪峰大大的教程再干起来吧!
呵呵哒哒问题解决了……之前的master完全混乱了,于是姐用了个最简单粗暴的方法,先remove远程的仓库再git remote add origin https://gitee.com/LTLT666/firstproj.git重新连回来……然后世界终于清静了!push成功!

$ git add learnexam.py
$ git add MGT002R_Buyer_Quality_Metrics_10_Oct-2017.txt
$ git add MGT002R_Buyer_Quality_Metrics_10_Oct-2017.xlsx
$ git commit -m"re-add remote origin and add 3 files from company"
$ git push origin master
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (17/17), 314.16 KiB | 10.47 MiB/s, done.
Total 17 (delta 4), reused 0 (delta 0)
To https://gitee.com/LTLT666/firstproj.git
   edb3153..335c8c3  master -> master
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值