git clone 与 git pull的区别
[smbtest@localhost a]$ git init
[smbtest@localhost a]$ git clone [remote_repo_path]
[smbtest@localhost a]$git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test/
nothing added to commit but untracked files present (use "git add" to track)
[smbtest@localhost a]$ git log
fatal: bad default revision 'HEAD'
[smbtest@localhost a]$ git branch
[smbtest@localhost a]$ git init
[smbtest@localhost a]$ git pull [remote_repo_path]
[smbtest@localhost b]$ git status
# On branch master
nothing to commit (working directory clean)
[smbtest@localhost b]$ git log
commit 4ab6b6d53b77ba41ca94a443a6d6cf00acdfcb42
…….
[smbtest@localhost git_study]$diff -r a/.git/ b/.git/
Only in b/.git/: FETCH_HEAD
Binary files a/.git/index and b/.git/index differ
Only in b/.git/: logs
Only in b/.git/objects/pack: pack-9a714c6fd30c1addc0648e809907bb09ebff0230.idx
Only in b/.git/objects/pack: pack-9a714c6fd30c1addc0648e809907bb09ebff0230.pack
Only in b/.git/refs/heads: master
[smbtest@localhost b]$ git branch
* master
由上可见,git clone只是简单的把远端库中的内容拷贝到本地,并没有建立分支,因此拷过来的内容还没有加入tracking,也没有log信息;而git pull自动建立了master分支,内容(包括log)与远端库一致。
即使是git clone,如果要进行库操作git init也是不可缺少的:
[smbtest@localhost c]$ git clone ssh://git@sny-jira.ads.finisar.com:7999/gpon/test.git
Cloning into 'test'...
remote: Counting objects: 671, done.
remote: Compressing objects: 100% (316/316), done.
remote: Total 671 (delta 287), reused 612 (delta 263)
Receiving objects: 100% (671/671), 801.00 KiB | 88 KiB/s, done.
Resolving deltas: 100% (287/287), done.
[smbtest@localhost c]$ git status
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
[smbtest@localhost c]$ git log
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
[smbtest@localhost c]$