10Ԫ 50Ԫ





֤룺  ֤,?ˢ֤



  Ҫ Ŀ Lib Ƶ Code iProcess γ ֤ ѯ   ɳ֮·  
Ա   
 
   
 
  
ÿ15ƪ
ı
׷
 
 
     
   
 
 
25 Git ׼
 
ߣAndy Jeffries Դlinux.cn  2015-6-4
1190     ۣ      
 

Ѿʹgit18ˣԼӦѾdz˽⡣ȻGitHubScott ChaconLVSѵڵһѧ˺ܶࡣ

ΪһgitоõˣҾ÷յһЩмֵϢҲܰij˽̫о

1. װĵһ

ڰװgitһֺ͵䣬ΪÿύҪõЩϢ

$ git config --global user.name "Some One"
$ git config --global user.email "someone@gmail.com"

2. Gitǻָ

gitһжļ㴴һύʱ򣬻ὨһύϢݣ֣ʼַ/ʱ䣬ǰһύȵȣļӵһļСļа˶бᵽĶ󣨻ƴǺͱύصʵݣҲһļ⣬ļûаڶǴ洢УЩļʹöSHA-1ϣֵΪļ

ַʽ֧ͱǩǼ򵥵ļָύSHA-1ϣֵʹЩԺٶȣ紴һ·֧Ǽ򵥵÷ֳֺ֧ǸύSHA-1һļȻ㲻ҪԼЩֻҪʹGitйߣGUIʵϾô򵥡

Ҳ˵HEADֻǼ򵥵һļ㵱ǰָǸύSHA-1ֵڽһκϲͻȻ󿴵HEADⲢһرķ֧֧ϵһλãֻDZ㵱ǰλá

еķָ֧붼.git/refs/headsHEAD.git/HEADǩ.git/refs/tags - Լȥ

3. ְ֣ڵ㣩 - û

ʷв鿴һϲύϢʱ㽫ڵ㣨ͬڹϵijύһڵڵķ֧ڶϲķ֧

4. ϲͻ

ĿǰϲͻҽͨDZ༭һļȥ<<<<====>>>>־ҪµĴ롣ʱܹ޸֮ǰĴܲ磬ڳͻķ֧֮ǰĸĶһַʽ

$ git diff --merge
diff --cc dummy.rb
index 5175dde,0c65895..4a00477
--- a/dummy.rb
+++ b/dummy.rb
@@@ -1,5 -1,5 +1,5 @@@
class MyFoo
def say
- puts "Bonjour"
- puts "Hello world"
++ puts "Annyong Haseyo"
end
end

ǶļȽϲûô...ͨҪľDzļ汾ĸڶļ༭ֹƳͻ֣һض֧ȡļ˵ںϲmasterfeature123֧

$ git checkout master flash/foo.fla # ...
$ git checkout feature132 flash/foo.fla
$ # Ȼ...
$ git add flash/foo.fla

һַʽͨgitļ - ļȻҪĸٽѡȷļΪļ

$ git show master:flash/foo.fla > master-foo.fla
$ git show feature132:flash/foo.fla > feature132-foo.fla
$ # master-foo.flafeature132-foo.fla
$ # ˵Ǿfeature132ļȷ
$ rm flash/foo.fla
$ mv feature132-foo.fla flash/foo.fla
$ rm master-foo.fla
$ git add flash/foo.fla

£лCarlԭѣʵϿágit checkout ours flash/foo.fla͡git checkout theirs flash/foo.flaض汾ļüסںϲķ֧֡Ҹ˵ϲȷһ㣬Ҳһַʽ...

ڽͻҪļύ

֧ͱǩ

5. Զ˷

gitһǿĹܾǿвֹһԶ˷ʵһֱһزֿϹ㲢һҪЩдȨޣжԶȡķϲǵĹȻд뵽һֿ⡣һµԶ˷ܼ򵥣

$ git remote add john git@github.com:johnsomeone/someproject.git

鿴Զ˷Ϣ

 ʾÿԶ˷URL
$ git remote -v
# ṩϸϢ
$ git remote show name

ʱԲ鿴ط֧Զ˷֧IJ죺

$ git diff master..john/master

ҲԲ鿴ûԶ˷֧ϵHEADĸĶ

$ git log remote/branch..
# ע⣺..ûнض

6. ǩ

git͵ıǩ - ǩʹעͱǩס2˵gitǻָģ֮IJҲܼ򵥡ǩֻһ򵥵ָһύĴָ롣ʱԽָһύעͱǩһָǩĴָ룬ԼϢʷΪԼϢԸҪGPGǩ

͵ıǩܼ򵥣ֻһпصIJ죩

$ git tag to-be-tested
$ git tag -a v1.1.0 # ʾǩϢ

7. ֧

gitィ֧dz򵥣һ죬ΪֻҪһС100ֽڵļͨʽ·֧лȥ

$ git branch feature132
$ git checkout feature132

ȻȷԼֱл½ķ֧һʵ֣

$ git checkout -b feature132

һط֧Ҳܼ򵥣ʾʲôĽϳķʽ

$ git checkout -b twitter-experiment feature132
$ git branch -d feature132

£ҲԣBrian Palmerԭµģֻágit branch-mһʵ֣Mikeģָֻһ֧ͻǰ֧

$ git branch -m twitter-experiment
$ git branch -m feature132 twitter-experiment

8. ϲ֧

ҲڽijʱϣĶϲַʽ

$ git checkout master
$ git merge feature83 # ...
$ git rebase feature83

mergerebase֮IJmerge᳢ԴĶһµĻߵύrebase᳢԰һ֧һηиĶһӵ÷֧HEADϡѾ֧ƵԶ˷Ҫrebase - ͻ/⡣

㲻ȷЩ֧ϻжеĹ - Ҳ֪Щ֧ҪϲЩɾgit branchؿ԰㣺

# ʾѾȫϲǰ֧ķ֧
$ git branch --merged
# ʾûкϲǰ֧ķ֧
$ git branch --no-merged

9. Զ˷֧

ڱһ֧ϣƵԶ˷ϣһȥ

$ git push origin twitter-experiment:refs/heads/twitter-experiment
# originǷ֣twitter-experimentǷ֧

£лErlendԭϵ - ʵϺgit push origin twitter-experimentЧһʹ﷨֮ʹòͬķ֧ط֧add-ssl-supportԶissue-1723

Զ˷ɾһ֧ע֧ǰðţ

$ git push origin :twitter-experiment

鿴Զ˷֧״̬

$ git remote show origin

ܻгһЩǰйѾ˵ķ֧㱾ط֧

$ git remote prune

ڱظһԶ˷֧ͨķʽǣ

$ git branch --track myfeature origin/myfeature
$ git checkout myfeature

°gitʹ-bǼ֧ʱԶ趨٣

$ git checkout -b myfeature origin/myfeature

ڴص㣬ļϵͳб

10.

git԰ѵǰ״̬ŽһضջУȻȡ򵥵

$ git stash
# ...
$ git stash pop

˽ʹgit stash applypopĻһܳĴбpopȫغԶӶջƳʹùgit stash applyҲʹӶջƳһ

$ git stash drop

gitڵǰύϢԶۡϣԶϢĻΪܺǰһύûκϵ

$ git stash save "My stash message"

ϣбȡһضĴص㣨һǵһгȻķʽȡ

$ git stash list
stash@{0}: On master: Changed to German
stash@{1}: On master: Language is now Italian
$ git stash apply stash@{1}

11. ʽ

subversionֻ޸ļȻύиĶgitǿöķʽύļDzֲύļļеIJָĶҪ뽻ʽģʽ

$ git add -i
staged unstaged path
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
What now>

һڲ˵Ľʽʾʹеֻĸն˸ĻӦģʽȻֻϣļˣʹĸʽ11-42,4,7

벹ģʽʽģʽ°p5Ҳֱӽ룺

$ git add -p    
diff --git a/dummy.rb b/dummy.rb
index 4a00477..f856fb0 100644
--- a/dummy.rb
+++ b/dummy.rb
@@ -1,5 +1,5 @@
class MyFoo
def say
- puts "Annyong Haseyo"
+ puts "Guten Tag"
end
end
Stage this hunk [y,n,q,a,d,/,e,?]?

Կ·һЩѡѡӸļĶļиĶȵȡʹá?ϸЩѡ

12. ļϵͳﱣ/ȡظĶ

ЩĿGitĿgitļϵͳֱӱļûнǼ뵽汾С

Ǵgitд洢һļʼ

$ echo "Foo" | git hash-object -w --stdin
51fc03a9bb365fae74fd2bf66517b30bf48020cb

ĿļѾ浽ݿˣû趨һָָĻᱻա򵥵ķʽ趨һǩ

$ git tag myfile 51fc03a9bb365fae74fd2bf66517b30bf48020cb

עʹ˱ǩmyfileҪʹļʱ

$ git cat-file blob myfile

һЩļã߿ܻõ룬GPGԿȵȣֲϣÿζӲ̣ʵʹУ

   
 
 

ÿչ
ƶЧù
ùҪʵַ
ĵ

ù
ùƤ
CM09_Cù׼
ʹSVNа汾
ؿγ

ùʵ
ùӦ
μù
Ʒ
 

ù⡢Ŀ
ù淶
CQWeb 7.1ָܲ
ΪʲôҪʹClearCase
ClearCaseRTCļ
ClearQuest вԹ
...   

Ʒ
ùʵ
μù
ʹCCCQĿʵ
CVSù
SubversionԱ
γ...   

ѯ
SCMѯ
SCM̹淶ѯ
SCMѯ
ѯ...   

ùʵ֯Ŀ
ͨԺ ù淶Ӧ
ùչ
˹ ClearCaseù
йƶ ù
й ù
Ƽ ùPvcs
 
 
 
 
 
ÿ2ĵ/Ƶ
ɨ΢Ŷά붩
ļ¿
ÿ300Դ
 
 

| ϵ | ICP10020922 110108001071