git 命令的使用(一) add commit push pull

一. commit 和 push 的区别

git作为支持分布式版本管理的工具,它管理的库(repository)分为本地库、远程库。

git commit操作的是本地库,git push操作的是远程库。

git commit是将本地修改过的文件提交到本地库中。

git push是将本地库中的最新信息发送给远程库。

git pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。它的完整格式稍稍有点复杂。

git pull = git fetch + git merge

注:git add之前,应该先git pull一下;git add 后面是空文件夹的话,添加不上

 1 [ch@1httg6tZ crawler]$ cd wcg
 2 [ch@1httg6tZ wcg]$ ls
 3 test2.py  test.py
 4 [ch@1httg6tZ wcg]$ vim test1.py                 #把刚创建的文件添加到git
 5 [ch@1httg6tZ wcg]$ git add test1.py             #添加文件
 6 [ch@1httg6tZ wcg]$ git commit -m 'add new file' #将本地修改的文件提交到本地库中
 7 [master 65ae9e8] add new file                                     
 8  1 file changed, 1 insertion(+)
 9  create mode 100644 wcg/test1.py
10 [ch@1httg6tZ wcg]$ git push                     #把本地保存的信息发送到服务器里面
11 warning: push.default is unset; its implicit value is changing in
12 Git 2.0 from 'matching' to 'simple'. To squelch this message
13 and maintain the current behavior after the default changes, use:
14 
15   git config --global push.default matching
16 
17 To squelch this message and adopt the new behavior now, use:
18 
19   git config --global push.default simple
20 
21 See 'git help config' and search for 'push.default' for further information.
22 (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
23 'current' instead of 'simple' if you sometimes use older versions of Git)
24 
25 Password for 'https://chenguang@123.56.178.186:8443':
26 Counting objects: 6, done.
27 Delta compression using up to 4 threads.
28 Compressing objects: 100% (3/3), done.
29 Writing objects: 100% (4/4), 364 bytes | 0 bytes/s, done.
30 Total 4 (delta 1), reused 0 (delta 0)
31 remote: Resolving deltas: 100% (1/1)
32 remote: Updating references: 100% (1/1)
33 To https://chenguang@123.56.178.186:8443/r/crawler.git
34    c0c026f..65ae9e8  master -> master
35 [ch@1httg6tZ wcg]$ git pull
36 Password for 'https://chenguang@123.56.178.186:8443':
37 Already up-to-date.
38 [ch@1httg6tZ wcg]$

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值