ºìÁªLinuxÃÅ»§
Linux°ïÖú

LinuxÏÂGitºÍGitHubʹÓ÷½·¨×ܽá

·¢²¼Ê±¼ä:2014-06-07 10:54:55À´Ô´:ºìÁª×÷Õß:velcbo
1 LinuxÏÂGitºÍGitHub»·¾³µÄ´î½¨

µÚÒ»²½£º °²×°Git£¬Ê¹ÓÃÃüÁî ¡°sudo apt-get install git¡±

µÚ¶þ²½£º ´´½¨GitHubÕʺÅ

µÚÈý²½£º Éú³Éssh key£¬Ê¹ÓÃÃüÁî ¡°ssh-keygen -t rsa -C "your_email@youremail.com"¡±£¬your_emailÊÇÄãµÄemail

µÚËIJ½£º »Øµ½github£¬½øÈëAccount Settings£¬×ó±ßÑ¡ÔñSSH Keys£¬Add SSH Key,titleËæ±ãÌճÌùkey¡£

µÚÎå²½£º ²âÊÔssh keyÊÇ·ñ³É¹¦£¬Ê¹ÓÃÃüÁî¡°ssh -T git@github.com¡±£¬Èç¹û³öÏÖYou¡¯ve successfully authenticated, but GitHub does not provide shell access ¡£Õâ¾Í±íʾÒѳɹ¦Á¬ÉÏgithub¡£

µÚÁù²½£º ÅäÖÃGitµÄÅäÖÃÎļþ£¬usernameºÍemail

git config --global user.name "your name" //ÅäÖÃÓû§Ãû

git config --global user.email "your email" //ÅäÖÃemail

2 ÀûÓÃGit´Ó±¾µØÉÏ´«µ½GitHub

µÚÒ»²½£º ½øÈëÒªËùÒªÉÏ´«ÎļþµÄĿ¼ÊäÈëÃüÁî ¡°git init¡±

µÚ¶þ²½£º ´´½¨Ò»¸ö±¾µØ²Ö¿âorigin£¬Ê¹ÓÃÃüÁî ¡°git remote add origin git@github.com:yourName/yourRepo.git¡±
younameÊÇÄãµÄGitHubµÄÓû§Ãû£¬yourRepoÊÇÄãÒªÉÏ´«µ½GitHubµÄ²Ö¿â

µÚÈý²½£º ±ÈÈçÄãÒªÌí¼ÓÒ»¸öÎļþxxxµ½±¾µØ²Ö¿â£¬Ê¹ÓÃÃüÁî ¡°git add xxx¡±£¬¿ÉÒÔʹÓá°git add .¡±×Ô¶¯ÅжÏÌí¼ÓÄÄЩÎļþ

È»ºó°ÑÕâ¸öÌí¼ÓÌá½»µ½±¾µØµÄ²Ö¿â£¬Ê¹ÓÃÃüÁî ¡±git commit -m ¡±ËµÃ÷Õâ´ÎµÄÌá½»¡° ¡°

×îºó°Ñ±¾µØ²Ö¿âoriginÌá½»µ½Ô¶³ÌµÄGitHub²Ö¿â£¬Ê¹ÓÃÃüÁî ¡±git push origin master¡°

3 ´ÓGitHub¿Ë¡ÏîÄ¿µ½±¾µØ

µÚÒ»²½£º µ½GitHubµÄij¸ö²Ö¿â£¬È»ºó¸´ÖÆÓұߵÄÓиö¡°HTTPS clone url¡±

µÚ¶þ²½£º »Øµ½Òª´æ·ÅµÄĿ¼Ï£¬Ê¹ÓÃÃüÁî "git clone https://github.com/chenguolin/scrapy.git"£¬ºìÉ«µÄurlÖ»ÊÇÒ»¸öÀý×Ó

µÚÈý²½£º Èç¹û±¾µØµÄ°æ±¾²»ÊÇ×îеģ¬¿ÉÒÔʹÓÃÃüÁî ¡°git fetch origin¡±£¬originÊDZ¾µØ²Ö¿â

µÚËIJ½£º °Ñ¸üеÄÄÚÈݺϲ¢µ½±¾µØ·ÖÖ§£¬¿ÉÒÔʹÓÃÃüÁî ¡°git merge origin/master¡±

Èç¹ûÄã²»ÏëÊÖ¶¯È¥ºÏ²¢£¬ÄÇôÄã¿ÉÒÔʹÓ㺠git pull <±¾µØ²Ö¿â> master // Õâ¸öÃüÁî¿ÉÒÔÀ­È¥×îа汾²¢×Ô¶¯ºÏ²¢

4 GitHubµÄ·ÖÖ§¹ÜÀí

´´½¨

1 ´´½¨Ò»¸ö±¾µØ·ÖÖ§£º git branch <зÖÖ§Ãû×Ö>

2 ½«±¾µØ·Ö֧ͬ²½µ½GitHubÉÏÃ棺 git push <±¾µØ²Ö¿âÃû> <зÖÖ§Ãû>

3 Çл»µ½Ð½¨Á¢µÄ·ÖÖ§£º git checkout <зÖÖ§Ãû>

4 ΪÄãµÄ·ÖÖ§¼ÓÈëÒ»¸öеÄÔ¶³Ì¶Ë£º git remote add <Ô¶³Ì¶ËÃû×Ö> <µØÖ·>

5 ²é¿´µ±Ç°²Ö¿âÓм¸¸ö·ÖÖ§: git branch

ɾ³ý

1 ´Ó±¾µØɾ³ýÒ»¸ö·ÖÖ§£º git branch -d <·ÖÖ§Ãû³Æ>

2 ͬ²½µ½GitHubÉÏÃæɾ³ýÕâ¸ö·ÖÖ§£º git push <±¾µØ²Ö¿âÃû> :

5 ³£¼û´íÎó

1 Èç¹û³öÏÖ±¨´íΪERROR: Repository not found.fatal: The remote end hung up unexpectedlyÔò´ú±íÄãµÄ origin µÄurl Á´½ÓÓÐÎ󣬿ÉÄÜÊÇ´´½¨´íÎó£¬Ò²¿ÉÄÜÊÇÕâ¸ö git@github.com:xxx/new-project.git url Ö¸¶¨²»ÕýÈ·¡£ÖØд´½¨¡£

×÷Õߣºchenguolin
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ