gitÔõôÐÞ¸Äorigin
gitÊÇÒ»¿îÂþÑÜʽ°æ±¾¿ØÖÆϵͳ£¬Ëü¿ÉÒÔ×ÊÖúÎÒÃǸßЧµØÖÎÀí´úÂë¡£ÔÚʹÓÃgitµÄÀú³ÌÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒª¶ÔÔ¶³Ì¿ÍÕ»¾ÙÐÐһЩÐ޸ģ¬ºÃ±È¸ü¸ÄÔ¶³Ì¿ÍÕ»µÄÃû³Æ»òurl¡£±¾ÎĽ«ÏÈÈÝÔõÑùͨ¹ýgitÐÞ¸Äorigin¡£
Ò»¡¢GitÖеÄorigin
ÔÚGitÖУ¬originÊÇĬÈϵÄÔ¶³Ì¿ÍÕ»Ãû³Æ¡£µ±ÎÒÃÇʹÓÃÒÔÏÂÏÂÁÍâµØ¿ÍÕ»ÓëÔ¶³Ì¿ÍÕ»¹ØÁªÊ±£¬Git¾Í»á×Ô¶¯Ìí¼ÓÒ»¸öÃûΪoriginµÄÔ¶³Ì¿ÍÕ»£º
git remote add origin <url></url>
µÇ¼ºó¸´ÖÆ
ÔÚÖ´ÐиÃÏÂÁîºó£¬ÎÒÃDZã¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÍâµØ´úÂëÉÏ´«ÖÁ¶ÔÓ¦µÄÔ¶³Ì¿ÍÕ»£º
git push -u origin <branch></branch>
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊöÏÂÁîÖУ¬¡°origin¡±Ö¸´úÔ¶³Ì¿ÍÕ»Ãû³Æ£¬¡°branch¡±Ö¸´ú·ÖÖ§Ãû³Æ¡£
¶þ¡¢ÐÞ¸ÄoriginµÄURL
ÔÚijЩÇéÐÎÏ£¬ÎÒÃÇ¿ÉÄÜÐèÒªÐÞ¸ÄÔ¶³Ì¿ÍÕ»µÄURL¡£ºÃ±È£¬µ±ÎÒÃǵÄÔ¶³Ì¿ÍÕ»ËùÔÚЧÀÍÆ÷±¬·¢ÁËת±ä£¬»òÕßÎÒÃÇÐèÒª½«Ô¶³Ì¿ÍÕ»µÄURL´ÓHTTPÐÒéÇл»ÖÁSSHÐÒéʱ£¬¾ÍÐèÒªÐÞ¸ÄÔ¶³Ì¿ÍÕ»µÄURL¡£
ÒÔÏÂÊÇÐÞ¸ÄÔ¶³Ì¿ÍÕ»URLµÄ°ì·¨£º
Ö´ÐÐÒÔÏÂÏÂÁîÉó²éÄ¿½ñÔ¶³Ì¿ÍÕ»µÄURL£º
git remote -v
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
Êä³öЧ¹ûÓ¦¸ÃÀàËÆÓÚÒÔÏÂÄÚÈÝ£º
origin https://github.com/username/repo.git (fetch) origin https://github.com/username/repo.git (push)
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÒÔÏÂÏÂÁîÐÞ¸ÄÔ¶³Ì¿ÍÕ»µÄURL£º
git remote set-url origin <newurl></newurl>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬¡°newURL¡±ÎªÐµÄÔ¶³Ì¿ÍÕ»URL¡£
¾ÙÀýÀ´Ëµ£¬ÈôÊÇÎÒÃÇÒª½«Ô¶³Ì¿ÍÕ»µÄURL´ÓHTTPSÐÒéÇл»ÖÁSSHÐÒ飬¿ÉÒÔÖ´ÐÐÒÔÏÂÏÂÁ
git remote set-url origin git@github.com:username/repo.git
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÍêÉÏÊöÏÂÁîºó£¬ÎÒÃÇ¿ÉÒÔÔÙ´ÎÖ´ÐÐÒÔÏÂÏÂÁîÉó²éÄ¿½ñÔ¶³Ì¿ÍÕ»µÄURL£¬È·±£ÐÞ¸ÄÒÑÉúЧ£º
git remote -v
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
Êä³öЧ¹ûÓ¦¸ÃÀàËÆÓÚÒÔÏÂÄÚÈÝ£º
origin git@github.com:username/repo.git (fetch) origin git@github.com:username/repo.git (push)
µÇ¼ºó¸´ÖÆ
Èý¡¢ÐÞ¸ÄoriginµÄÃû³Æ
ÔÚijЩÇéÐÎÏ£¬ÎÒÃÇ¿ÉÄÜÐèÒªÐÞ¸ÄÔ¶³Ì¿ÍÕ»µÄÃû³Æ¡£ºÃ±È£¬µ±ÎÒÃÇÏëҪͬʱ½«´úÂëÉÏ´«ÖÁ¶à¸öÔ¶³Ì¿Íջʱ£¬¿ÉÒÔΪÿ¸ö¿ÍÕ»Ìí¼Ó²î±ðµÄÃû³Æ¡£
ÒÔÏÂÊÇÐÞ¸ÄÔ¶³Ì¿ÍÕ»Ãû³ÆµÄ°ì·¨£º
Ö´ÐÐÒÔÏÂÏÂÁîÉó²éÄ¿½ñÔ¶³Ì¿ÍÕ»µÄÃû³Æ£º
git remote
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
Êä³öЧ¹ûÓ¦¸ÃÖ»°üÀ¨Ò»¸öÃû³Æ£¬¼´¡°origin¡±¡£
Ö´ÐÐÒÔÏÂÏÂÁîÐÞ¸ÄÔ¶³Ì¿ÍÕ»µÄÃû³Æ£º
git remote rename origin <newname></newname>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬¡°newName¡±ÎªÐµÄÔ¶³Ì¿ÍÕ»Ãû³Æ¡£
¾ÙÀýÀ´Ëµ£¬ÈôÊÇÎÒÃÇÏëÒª½«Ô¶³Ì¿ÍÕ»µÄÃû³Æ´Ó¡°origin¡±ÐÞ¸ÄΪ¡°upstream¡±£¬¿ÉÒÔÖ´ÐÐÒÔÏÂÏÂÁ
git remote rename origin upstream
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÍêÉÏÊöÏÂÁîºó£¬ÎÒÃÇ¿ÉÒÔÔÙ´ÎÖ´ÐÐÒÔÏÂÏÂÁîÉó²éÄ¿½ñÔ¶³Ì¿ÍÕ»µÄÃû³Æ£¬È·±£ÐÞ¸ÄÒÑÉúЧ£º
git remote
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
Êä³öЧ¹ûÓ¦¸ÃÖ»°üÀ¨Ò»¸öÃû³Æ£¬¼´¡°upstream¡±¡£
×ܽá
ÔÚʹÓÃGitÖÎÀí´úÂëµÄÀú³ÌÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒª¶ÔÔ¶³Ì¿ÍÕ»¾ÙÐÐһЩÐ޸ġ£Í¨¹ý±¾ÎÄÏÈÈݵÄÒªÁ죬ÎÒÃÇ¿ÉÒÔÇáËɵØÐÞ¸ÄÔ¶³Ì¿ÍÕ»µÄURLºÍÃû³Æ¡£Ï£Íû±¾ÎÄÄܶÔʹÓÃGitµÄ¿ª·¢ÕßÃÇÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇgitÔõôÐÞ¸ÄoriginµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡