- 論壇徽章:
- 0
|
今天開始git工具的學(xué)習(xí)之旅了,引用git官網(wǎng)git-scm.com上的話:
Git
is a free & open source, distributed version control system
designed to handle everything from small to very large projects with
speed and efficiency.
看了上面這句話就基本知道了git的優(yōu)點(diǎn)就是快速,分布式的管理,適合于各種規(guī)模的項目開發(fā)。
先安裝git工具:
我使用的是ubuntu操作系統(tǒng),git工具在ubuntu軟件源中有。于是先安裝git工具包
sudo
apt-get install git git-core gitk
這樣我們就安裝好了git工具了
git的相關(guān)文檔資源在http://git-scm.com/可以找到,在網(wǎng)站上Documentation上提供兩種文檔形式:Tutorials和Reference.我們?yōu)榱烁斓氖煜it先參考o(jì)fficial git tutorial文檔學(xué)習(xí)。
初識:
1.可以輸入man
git-log或git
help log來查看git的幫助
2.在使用git之前需要把自己的信息提供給git,比如自己的姓名、email。命令如下:
git config --global user.name
“Your Name”
git config --global user.email
“you@example.com”
我執(zhí)行的是:
$ git config --global user.name
wei
$ git config --global
user.email
wei339@gmail.com
導(dǎo)入新項目:
假設(shè)需要導(dǎo)入新項目git4test.tar.bz2
tar jxvf git4test.tar.bz2
cd
git4test
git
init
Initialized
empty Git repository in /home/weijianhua/git4test/.git/
git
init命令用于初始化當(dāng)前所在目錄的這個項目,在git4test下已經(jīng)建立了一個.git隱藏目錄來保存這個項目目前的進(jìn)展信息。我們可以用ls
-a看到它。
weijianhua@wjh-laptop:~/git4test$
ls -lha
總用量
16K
drwxr-xr-x
3 weijianhua weijianhua 4.0K 2009-04-15 22:12 .
drwxrwxrwx
49 weijianhua weijianhua 4.0K 2009-04-15 22:12 ..
drwxr-xr-x
7 weijianhua weijianhua 4.0K 2009-04-15 22:12 .git
-rw-r--r--
1 weijianhua weijianhua 80 2009-04-15 22:12 main.c
提交代碼:
1.先執(zhí)行g(shù)it
add . (add后有一空格)
這個命令要求git給目前的項目制作一個snapshot,暫時存儲在一個臨時存儲區(qū)域中。
2.git
commit
用于將snapshot里登記的內(nèi)容永久寫入git中,也就是要提交自己的代碼了。
在輸入git
commit會出現(xiàn)一個文本編輯窗口,要我們輸入這次提交的版本和開發(fā)信息。
我執(zhí)行的情況:
weijianhua@wjh-laptop:~/git4test$
git add .
weijianhua@wjh-laptop:~/git4test$
git commit
Created
initial commit 09639b4: version 1.0 by wei 20090415 wei339@gmail.com
1
files changed, 7 insertions(+), 0 deletions(-)
create
mode 100644 main.c
今天先學(xué)習(xí)這么多,明天繼續(xù)……
本文來自ChinaUnix博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u2/65429/showart_1901886.html |
|