第ä¸ï¼ä¸è½½å¹¶å®è£
git
ç®åwindowsçæ¬çgitæå ç§å®ç°ï¼ä½æ们éæ©msysgitåè¡çï¼è¿æ¯ç®ååå¾å
¼å®¹æ§æ好çã
ä¸è½½å°åï¼
http://code.google.com/p/msysgit/downloads/list使ç¨é»è®¤é
ç½®å®è£
Gitãè¿ä¸ªä¸ç¨å¤è¯´ï¼ä¸è·¯Nextå°±å¯ä»¥ï¼å¦æ对åç§é项ä¸çæï¼å»ºè®®ä½¿ç¨é»è®¤é
ç½®ï¼æ²¡é®é¢çã
第äºï¼å建githubè´¦å·
ä»ä¹æ¯GitåGitHub
Git âThe stupid content tracker, å»çå
容è·è¸ªå¨ï¼æ¯ä¸ä¸ªç±Linuxå
æ ¸å¼åè
Linus为äºæ´å¥½å°ç®¡çLinuxå
æ ¸å¼åèåç«çåå¸å¼çæ¬æ§å¶è½¯ä»¶ã
GitHub â å¦çåçæ¬æ§å¶æ讨åçå°±æ¯æ¾æå¡å¨ï¼é
置太麻ç¦äºãGitHubè¿ä¸ªç½ç«ä¸ºæ¯ä¸ªç¨æ·æä¾æå¡å¨æ管å
¶Git代ç åºï¼å
费空é´ä¸º300Mã注åGitHubåä½ å°±ä¼æ0.3Gçå
费空é´ï¼ä¸è¿åªè½å建å
¬å¼é¡¹ç®ã
为ä»ä¹ä¸éCVSæSVN
Gitæ交/å
é/pull/pushçé度æ´å¿«
Gitçç»å¤§å¤æ°æä½é½å¯ä»¥å¨æ¬å°å®æï¼ä¸éè¦é¢ç¹è¿æ¥æå¡å¨ã
注åGitHubè´¦å·
GitHubç½åå¨ è¿é
ç¹å»ä¸æ¹å¯¼èªæ¡çSignup and Pricingå³å¯è¿å
¥æ³¨åçé¢ï¼ éæ©æ³¨åå
费账æ·
GitHubéæ©çé»è®¤éä¿¡æ¹å¼æ¯SSHï¼æ以è¦å
å¨Gitéé¢çæSHH Keyï¼æå¼Git Bashå¨å
¶ä¸è¾å
¥å¦ä¸å½ä»¤ï¼
ssh-keygen -t rsa -C "
[email protected]"
ä¹åä¼è®©ä½ éæ©æ¯å¦å¯¹åæ¾SSH Keyçæ件夹è¿è¡å å¯ï¼ä¸è¬é½ä¸éè¦çãä¸è·¯å车ï¼å°±OKäºã
å¨cçï¼å½åç¨æ·æ件夹ä¸ï¼æ个.ssh æ件夹ï¼å¨éè¾¹ æ¾å° id_rsa.pubæ件ï¼ç¨è®°äºæ¬æå¼ï¼å¤å¶å
¶ä¸çå
¨é¨å
容ã
ç»éä½ çGitHubè´¦æ·ï¼ä¾æ¬¡ç¹å»Account Settings
>
SSH Public Keys
>
Add another public keyï¼æid_rsa.pubä¸çå
容æ·è´è¿å» ã
è³æ¤ï¼åºæ¬ç设置已ç»å®æäºã
æäºã
æµè¯ä½ çGit
ç»è¿ä¸è¿°é
ç½®ï¼ä½ çGtiåºè¯¥å¯ä»¥éè¿SSHè¿æ¥GitHubæå¡å¨äºï¼è®©æ们æ¥æµè¯ä¸ï¼è¾å
¥å¦ä¸å½ä»¤ï¼
ä¼ç»ä½ è¿æ ·çæ示ï¼
è¾å
¥yesï¼ä¼æ¾ç¤ºï¼
å°è¿éï¼è¯´æä½ çSSHè¿è½¬è¯å¥½ã
å¦ææç¤ºä½ çå¯é¥ä¸æ£ç¡®ï¼é£ä¹ä½ éè¦éæ°ç¡®è®¤ä¸ä¸æ¥çæä½æ¯å¦å®æ´æ 误ã
第ä¸ï¼å»ºç«æ¬å°gitä»åº
é¦å
ï¼gitè¦æ±ä½¿ç¨è
å¿
é¡»æä¾èªå·±ç身份æ è¯ï¼ä¸ºæ¤æ们éè¦å¨git bashä¸æ§è¡ä»¥ä¸å½ä»¤ï¼
git config --global user.name 'aa.Tessst'
git config --global user.email
[email protected]å
¶æ¬¡ï¼éæ©gitä»åºç®å½
æ们å设å°gitä»åºç®å½æ¾å¨DççOPENSourceç®å½ä¸ï¼å¯ä»¥éè¿å¨git bashä¸æ§è¡ä»¥ä¸å½ä»¤å®æï¼
cd /d
mkdir OPENSource
注ï¼git bashæ¯æ大å¤linux bashç»ç«¯å½ä»¤ï¼ä½ å¯ä»¥èªå·±å°è¯æ´å¤ç»ç«¯æä½ã
æåï¼å»ºç«é¡¹ç®å¹¶åå§ågitä»åº
æ们ç第ä¸ä¸ªé¡¹ç®æ¯ä¸ä¸ªä½¿ç¨Pythonè¯è¨å°XMLæ件转æ¢æPythonåå
¸ï¼éè¿æ§è¡ä»¥ä¸å½ä»¤å®ææ¤æ¥éª¤ï¼
mkdir Python-XML2Dict
cd Python-XML2Dict
git init
æ§è¡æ¤æä½åï¼gitå°å¨Python-XML2Dictç®å½ä¸å建ä¸ä¸ªéèç®å½ï¼.gitï¼ï¼è¿ä¸ªç®å½å°±æ¯gitç¨æ¥ç®¡ç软件çæ¬çä»åºã
第åï¼ä½¿ç¨git管ç项ç®
æ¤æ¥ å å¨linux ä¸ ä½¿ç¨ git ç æ¹æ³ä¸æ ·ï¼å
·ä½åè æç å
¶ä» åæï¼
第äºï¼å°é¡¹ç®æ交å°github管çï¼gitpush
å¦æ 第äºæ¥ æµè¯æ éï¼é£ä¹ ç»è¿ 以ä¸ä¸¤æ¥ å°±å¯ä»¥å°æ¬å°çæ件æ交å°githubä»åºäºã
1ãç»å½GitHubåï¼ä½ å¯ä»¥å¨å³ä¸è¾¹é ä¸é£éæ¾å°ä¸ä¸ªæé®âcreat a New Repositoryâï¼ç¹å»è¿åï¼å¡«å
¥é¡¹ç®å称ã说æç è¿åå°±å¯ä»¥å建äºï¼ç¶åä¼åºç°ä¸ä¸ªæ示页é¢ï¼è®°ä¸ç±»ä¼¼
[email protected]:XXX/XXX.git çå°åï¼è¿ä¸ªå°±æ¯ä½ è¿ä¸ªé¡¹ç®çå°åäºã
2ã
1 git remote add origin
[email protected]:XXX/XXX.git
2 git push -u origin master //ææ¬å° master åæ¯ æ¨éå° æå¡å¨çmasteråæ¯ä¸ï¼å¦ææå¡å¨æ²¡ææ¤åæ¯ï¼å°± æ°å»º æ¤åæ¯ãè¿ä¹æ¯ å¨æå¡å¨ä¸æ°å»ºåæ¯çä¸ç§æ¹æ³
è¿ä¸ª
[email protected]:XXX/XXX.gitå°±æ¯ä¸é¢å建项ç®æ¯çæçå°åãç°å¨æå¼ä½ ç项ç®ç½åï¼ä½ å°±å¯ä»¥åç°ä½ ç代ç å·²ç»å±ç¤ºåºæ¥äºã
第å
ï¼ç´æ¥ ç¨ git pull å°é¡¹ç® ä» github ä¸ åæ¥ ä¸æ¥
æ两ç§æ¹æ³ï¼
1ãå½git cloneä¹åï¼ç´æ¥git pullå®ä¼èªå¨å¹é
ä¸ä¸ªæ£ç¡®çremote url
æ¯å 为å¨configæ件ä¸é
ç½®äºä»¥ä¸å
容ï¼
1 [branch "master"]
2 remote = origin
3 merge = refs/heads/master
表æï¼
1.gitå¤äºmasterè¿ä¸ªbranchä¸æ¶ï¼é»è®¤çremoteå°±æ¯originï¼
2.å½å¨masterè¿ä¸ªbrachä¸ï¼ä½¿ç¨æå®remoteåmergeçgit pullæ¶ï¼ä½¿ç¨é»è®¤çremoteåmergeã
2ãä½æ¯å¯¹äºèªå·±å»ºç项ç®ï¼å¹¶æ²¡æè¿åå
容ï¼éè¦èªå·±é
ç½®ã
1 git remote add -f origin
[email protected]:/srv/git/project.git //è¥æ¯ æ§è¡è¿ 第äºæ¥ï¼é£ä¹ è¿ä¸å¥ å°± ä¸ç¨äº
2 git config branch.master.remote origin //è¿ä¸æ¥ è®¾ç½®ï¼ æ master åæ¯ä¸ ç é»è®¤æå¡å¨å°å 设为 originæåçå°å
3 git config branch.master.merge refs/heads/master //è¿ä¸æ¥ 设置ï¼å¦æå½ååæ¯æ¯ master åæ¯ï¼é£ä¹ git pullä¹åï¼ç´æ¥ æ âä» origin ä¸è½½ ä¸æ¥ç codeåå¹¶å° masteråæ¯ä¸â
æè
å ä¸--globalé项ï¼å¯¹äºå
¨é¨é¡¹ç®é½ä½¿ç¨è¯¥é
ç½®ã
建议ï¼ç¨ç¬¬äºç§ æ¹æ³ï¼å 为 å¦æ æ¯ git cloneç 项ç®ï¼å½ æ§è¡ git push æ¶ï¼å 为 å¨ git configé url æ¯ åªè¯»æ¹å¼
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/xxx/xxx.git
//
[email protected]:XXX/XXX.git è¿ææ¯ è¯»åæ¹å¼
---------------------------------
å¦ææ交äºææä¿¡æ¯ï¼æ¯å¦ä»£ç ä¸è®¾ç½®çèªå·±çå¯ç ä»ä¹çå¿å é¤å°±ä¸ä¼ ä¸å»äºæä¹åï¼
æ两个æ¹æ³ï¼
1ãéæ°ä¿®æ¹æ¬å°ä»£ç ï¼ç¶åæ交å°æå¡å¨ï¼è¦çï¼ï¼
2ãç´æ¥ç»å½ github å é¤ä¹åç项ç®ãå é¤é¡¹ç®éè¦å¨GitHubç½ç«ä¸å³ä¸æ¹æ¾å°adminæé®ï¼è¿å»åå³è¾¹æä¸é¢æ个å é¤çæé®ï¼è¿æ ·å°±å¯ä»¥å é¤äºã
--------------------------
è¥æ¯ä¸ä¸ªé¡¹ç®å°±æç®¡å¨ GitHub ä¸ãä½ å¯ä»¥æå®ç URL å享ç»æ¯ä½å¯¹æ¤é¡¹ç®æå
´è¶£ç人ãæ¬ä¾ç URL æ¯
http://github.com/testinguser/iphone_projectãèå¨é¡¹ç®é¡µé¢çæè¦é¨åï¼ä½ ä¼åç°æ两个 Git URL å°åï¼è§ å³å¾ï¼
å³å¾ç æè¦ä¸çå
Œ
± URL åç§æ URL
Public Clone URL æ¯ä¸ä¸ªå
¬å¼çï¼åªè¯»ç Git URLï¼ä»»ä½äººé½å¯ä»¥éè¿å®å
é该项ç®ãå¯ä»¥éææ£æè¿ä¸ª URLï¼æ¯å¦åå¸å°ä¸ªäººç½ç«ä¹ç±»çå°æ¹ççã
Your Clone URL æ¯ä¸ä¸ªåºäº SSH åè®®çå¯è¯»å¯å URLï¼åªæ使ç¨ä¸ä¸ä¼ ç SSH å
¬é¥å¯¹åºçå¯é¥æ¥è¿æ¥æ¶ï¼æè½éè¿å®è¿è¡è¯»åæä½ãå
¶ä»ç¨æ·è®¿é®è¯¥é¡¹ç®é¡µé¢æ¶åªè½çå°ä¹åé£ä¸ªå
Œ
±ç URLï¼çä¸å°è¿ä¸ªç§æç URLã