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 后面是空文件夹的话,添加不上

 [ch@1httg6tZ crawler]$ cd wcg
[ch@1httg6tZ wcg]$ ls
test2.py test.py
[ch@1httg6tZ wcg]$ vim test1.py #把刚创建的文件添加到git
[ch@1httg6tZ wcg]$ git add test1.py #添加文件
[ch@1httg6tZ wcg]$ git commit -m 'add new file' #将本地修改的文件提交到本地库中
[master 65ae9e8] add new file
file changed, insertion(+)
create mode wcg/test1.py
[ch@1httg6tZ wcg]$ git push #把本地保存的信息发送到服务器里面
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use: git config --global push.default matching To squelch this message and adopt the new behavior now, use: git config --global push.default simple See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git) Password for 'https://chenguang@123.56.178.186:8443':
Counting objects: , done.
Delta compression using up to threads.
Compressing objects: % (/), done.
Writing objects: % (/), bytes | bytes/s, done.
Total (delta ), reused (delta )
remote: Resolving deltas: % (/)
remote: Updating references: % (/)
To https://chenguang@123.56.178.186:8443/r/crawler.git
c0c026f..65ae9e8 master -> master
[ch@1httg6tZ wcg]$ git pull
Password for 'https://chenguang@123.56.178.186:8443':
Already up-to-date.
[ch@1httg6tZ wcg]$
上一篇:C/C++操作MySQL数据库——增、删、改、查


下一篇:JS高程5.引用类型(4)Array类型的各类方法