ããé¦å
ï¼ä¸è½½ä¸ä¸ªgitï¼å®è£
ã
ããå®è£
æåä¹åï¼è¾å
¥ä»¥ä¸å½ä»¤ï¼å¼å·å
çä¸ºä½ èªå·±çåååé®ç®±
ããgit config --global user.name "Your Name"
ããgit config --global user.email "
[email protected]"
ããå建ä¸ä¸ªçæ¬åºï¼å°±æ¯åæ¾å·¥ç¨çå°æ¹
ããmkdir æ件å
ããgit initï¼åå§åä»åºï¼
ããåå§åï¼åå§åä¹åï¼éè¿ls -ah å¯ä»¥çå°ç®å½ä¸å¤äºä¸ä¸ª.gitæ件
ããææ件添å å°çæ¬åº
ããé¦å
æ°å»ºä¸ä¸ªæ件ï¼test.htmlï¼ï¼å¯¹å
¶è¿è¡ç¼è¾å
容
ããgit add test.htmlï¼åªæ交å½åç®å½çtest.htmlæ件å°æ¬å°gitä»åºï¼
ããå¯è½ä¼åºç°å¦ä¸å¾ä¸çé误æ示
ããwarning: LF will be replaced by CRLF in test.html.
ããThe file will have its original line endings in your working directory.
ãã解å³æ¹æ³ï¼
ãã1ãå次è¾å
¥å¦ä¸å½ä»¤ï¼å¨å½ä»¤ä¹åå ä¸ä¸ªç©ºæ ¼ï¼å车
ãã2ãå¦æè¿æ¯ä¸è¡ï¼åæ§è¡git config core.autocrlf falseå½ä»¤ä¹åï¼å次æ§è¡addå½ä»¤å°±å¯æåã
ããæ§è¡git add .ï¼æææå
容添å å°ç´¢å¼åºä¸ï¼
ãã注æå½ä»¤ä¹åæ个.
ããæ交å°æ¬å°ä»åº
ããgit commit -m "wrote a readme file" ï¼æ交索å¼åºä¸çå
容ï¼-mæ¯åæ°ï¼è¡¨ç¤ºæ³¨éå
容ï¼ä¸»è¦ç¨æ¥è®°å½æ¤æ¬¡æä½ï¼
ããä¸ä¼ å°github
ãã使ç¨å¦ä¸å½ä»¤æ¥çærsaå
¬é¥
ããssh-keygen -t rsa -C "
[email protected]" ï¼æ¹æèªå·±çé®ç®±ï¼
ããå½ç¶ï¼é£ä¸ä¸ªåæ¾å°åçå½ä»¤ä½ ä¹å¯ä»¥ç´æ¥å车ï¼è®©å
¶é»è®¤åæ¾ï¼å¦å¾æ示ï¼ä¼æç¤ºä½ å
¬é¥æ件åæ¾ä½ç½®
ããè¿å
¥åæ¾ç®å½ï¼æå¼id_rsa.pubæ件ï¼å¤å¶éé¢çå
容ï¼ä¸è¬æ¯ä»¥ssh-rsaå¼å¤´
ããæå¼githubï¼æ³¨å/ç»å½èªå·±çè´¦å·
ããå¨è´¦æ·è®¾ç½®éé¢ï¼æ¾å°SSH and GPG keys设置ï¼ç¹å»New SSH keyï¼å°ä¹åå¤å¶çå
¬é¥å è¿å»å°±ok
ããå©ç¨å¦ä¸å½ä»¤æµè¯æ¯å¦è½è¿æ¥ä¸github
ããssh -t
[email protected]ï¼è¥ä¸æåï¼åå»æ-tåæ°ï¼
ããå¦ææ示ssh: Could not resolve hostname \342\200\223t: Name or service not known
ãã解å³åæ³ï¼
ããssh -t -p 22
[email protected] ï¼-p表示修æ¹æå¡å¨ç«¯å£ä¸º22ï¼
ããå½æ示è¾å
¥(yes/no)?æ¶å¨åé¢è¾å
¥yeså车å³å¯
ããå½çå°æ¬¢è¿è¯Hi oldinaction! You've successfully authenticated, but GitHub does not provide shell access.å表示é¾æ¥æåã
ããè¿å
¥å°è¦æ交æ件æå¨ç®å½ï¼git remote add origin
[email protected]:demo/0915.gitï¼
[email protected]:demo/0915.gitæ¯githubä¸å建项ç®çsshå°åï¼
ããæ示fatal: remote origin already exists é误解å³åæ³
ããå
git remote rm origin å é¤è¿ç¨
ããåè¿ç¨æ·»å ä»åºgit remote add origin
[email protected]:demo/0915.gitï¼åé¢çå°å
[email protected]:githubè´¦å·å/github项ç®å.gitï¼
ããå¦ææ§è¡ git remote rm origin æ¥éçè¯ï¼æ们å¯ä»¥æå¨ä¿®æ¹gitconfigæ件çå
容
ããvi .git/config
ããæ [remote âoriginâ] é£ä¸è¡å æ ä¿åéåºå³å¯ã
ããæ交å°githubä¸é¢
ããgit push -u origin masterï¼åæ交æåï¼æ¥çgithubï¼å°±å¯ä»¥çè§æ件已ç»ä¸ä¼ æå