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]$

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM