Git
ChiaChia Lee
Rails developer@Polydice Inc.
[email protected]
11年9月30日星期五
Slide 2
Slide 2 text
What is Git?
11年9月30日星期五
Slide 3
Slide 3 text
Git is...
11年9月30日星期五
Slide 4
Slide 4 text
Git is...
• distributed version control system
• with complete history
• not dependent on network access or a
central server
• Mercurial, Bazaar, Subversion, CVS,
Perforce, and Team Foundation Server
11年9月30日星期五
Slide 5
Slide 5 text
Git was...
• designed by Linus Torvalds (Linux
creator)
• for Linux kernel development
• at 2005.
11年9月30日星期五
Slide 6
Slide 6 text
Why Git is better than X
• http://zh-tw.whygitisbetterthanx.com/
• 便宜的本地分支
• 所有內容都在本地端
• Git很快
• Git很小
• Staging功能
• 分散式
• 適用任何工作流程
• GitHub rocks!
11年9月30日星期五
Slide 7
Slide 7 text
Projects using Git..
• Git
• Linux Kernel
• Perl
• Gnome
• Ruby on Rails
• Debian
• Eclipse
• Android
• X.org
• KDE
• Qt
• PostgreSQL
11年9月30日星期五
Slide 8
Slide 8 text
git commit -m “perfect commit”
10 common cases before push...
11年9月30日星期五
git commit -a
The “git commit -a” command is a shortcut to a two-step process.
11年9月30日星期五
Slide 21
Slide 21 text
Case6:git commit -am
• git commit -am = git commit -a + git commit -m
• $ vim a.txt
• $ vim b.txt
• $ git commit -am “modify a.txt and b.txt”
11年9月30日星期五
Slide 22
Slide 22 text
Case7:a new file...
If you create a new file named “new.txt”, edit it, and issue
the “git commit -a” command, you will see something like:
新檔案要記得先add
11年9月30日星期五
Slide 23
Slide 23 text
remove files
• (1)file system
• (2)git
• only (1):rm a.txt、按右鍵delete、...
• only (2):git rm --cached a.txt
• (1)+ (2):git rm a.txt
11年9月30日星期五
comparing commit
$ git diff
• $ git diff (沒add的)
• show you changes in the working directory
that are not yet staged for the next commit
• $ git diff --cached(有add的)
• show you the difference between the index
and your last commit
• $ git diff HEAD(全部)
• shows changes in the working directory
since your last commit
11年9月30日星期五
Slide 39
Slide 39 text
修改a&b
然後git add a.txt
git diff (only b)
git diff --cached (only a)
git diff HEAD (a & b)
11年9月30日星期五
Slide 40
Slide 40 text
references
• Git
• slideshare by ihower:Git and GitHub
• Git Tutorial
• "git commit -a" and "git add"
• Comparing Commits - Git Diff
• The Git Object Model (SHA)
• Why Git is Better than X
11年9月30日星期五