ÔõÑùÔÚGitÉÏÐÞ¸Äorigin
gitÊÇ¿ªÔ´µÄÂþÑÜʽ°æ±¾¿ØÖÆϵͳ£¬³£±»ÓÃÓÚÐͬ¿ª·¢´úÂë¡£ÔÚʹÓÃgitʱ£¬¾³£ÐèÒªÐÞ¸ÄgitµÄorigin£¬±¾ÎĽ«Îª¸÷ÈËÏêϸÏÈÈÝÔõÑùÔÚgitÉÏÐÞ¸Äorigin¡£
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏàʶʲôÊÇorigin¡£ÔÚGitÖУ¬originÊÇÒ»¸öÖ¸ÏòÔ¶³Ì¿ÍÕ»µÄÖ¸Õ룬ËüĬÈÏÖ¸ÏòÎÒÃÇ¿Ë¡»òÀÈ¡´úÂëµÄÔ´¿ÍÕ»¡£ÎÒÃÇͨ³£ÐèÒªÔÚ¾ÙÐдúÂëÉÏ´«Ê±ÓëÔ¶³Ì¿ÍÕ»¾ÙÐÐͨѶ£¬ÒÔ±ã°Ñ´úÂëºÏ²¢¡£Òò´Ë£¬¸ü¸ÄoriginÖ¸ÏòµÄÔ¶³Ì¿ÍÕ»£¬ÊǺÜÊÇÖ÷ÒªµÄ¡£
ÄÇô£¬ÔõÑùÐÞ¸ÄoriginÄØ£¿ÏÂÃæÎÒÃǽ«ÏÈÈÝÁ½ÖÖÐÞ¸ÄoriginµÄÒªÁì¡£
ÒªÁìÒ»£ºÊ¹ÓÃGitÏÂÁîÐÞ¸Äorigin
ÔÚʹÓÃGitʱ£¬Í¨³£ÎÒÃÇÐèҪͨ¹ýÏÂÁîÐеķ½·¨¾ÙÐвÙ×÷¡£ÈôÊÇÐèÒªÐÞ¸Äorigin£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐУº
$ git remote set-url origin <new-url></new-url>
µÇ¼ºó¸´ÖÆ
ÆäÖÐ ÊÇеĿÍÕ»µØµã¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÕâ¸öÏÂÁ½«originÖ¸ÏòÒ»¸öеÄÔ¶³Ì¿ÍÕ»µØµã¡£
ÀýÈ磬ÎÒÃÇÐèÒª½«Git¿ÍÕ»Ö¸Ïòhttps://github.com/my-name/my-repo.git£¬ÎÒÃÇ¿ÉÒÔÔÚÏÂÁîÐÐÖÐÊäÈëÒÔÏÂÏÂÁ
$ git remote set-url origin https://github.com/my-name/my-repo.git
µÇ¼ºó¸´ÖÆ
ÕâÑù£¬Git¿ÍÕ»µÄorigin¾ÍÖ¸ÏòÁËÎÒÃÇеÄÔ¶³Ì¿ÍÕ»µØµã¡£
ÒªÁì¶þ£ºÐÞ¸ÄgitÉèÖÃÎļþ
ÁíÍâÒ»ÖÖÒªÁìÊÇÖ±½ÓÐÞ¸ÄgitµÄÉèÖÃÎļþ¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÐÞ¸ÄÉèÖÃÎļþµÄ·½·¨£¬ÐÞ¸ÄGitµÄoriginÖ¸Ïò¡£
×ðÁú¿Ê±GitÉèÖÃÎļþͨ³£ÊÇÔÚ ~/.gitconfig ϵģ¬ÒÔÏÂÊÇÐÞ¸ÄÉèÖÃÎļþµÄÒªÁ죺
ÔÚÏÂÁî´°¿ÚÖз¿ªÉèÖÃÎļþ
$ open ~/.gitconfig
µÇ¼ºó¸´ÖÆ
ÕÒµ½ÉèÖÃÎļþÖÐµÄ [remote “origin”] ²¢ÐÞ¸Ä url ²ÎÊýΪеĿÍÕ»µØµã
[remote "origin"] url = https://github.com/my-name/my-repo.git
µÇ¼ºó¸´ÖÆ
ÉúÑÄÎļþ²¢Í˳ö
ÔÚÏÂÁîÐÐÖÐÔËÐÐ $ git fetch »ò $ git pull ÒÔ±ãʹ¸ü¸ÄÉúЧ
ÐèҪעÖصÄÊÇ£¬ÕâÖÖÐÞ¸ÄÒªÌå»áÓ°ÏìÕû¸öGitÇéÐΣ¬¶ø²»µ«½öÊÇÄ¿½ñµÄGit¿ÍÕ»¡£
×ܽá
ÔÚGitÖÐÐÞ¸ÄoriginÊǺÜÊǼòÆӵġ£ÎÒÃÇ¿ÉÒÔͨ¹ýGitÏÂÁî»òÕßÐÞ¸ÄgitÉèÖÃÎļþµÄÒªÁ죬À´Ö¸¶¨GitµÄoriginÖ¸Ïò¡£ÔÚÏÖʵʹÓÃÖУ¬Ó¦¸Ãƾ֤ÏêϸÇéÐÎÑ¡Ôñ×îÊʺϵÄÒªÁì¾ÙÐвÙ×÷¡£
×îºó£¬ÎÒÃÇÐèҪǿµ÷µÄÊÇ£¬ÔÚ¸ü¸ÄÔ¶³Ì¿ÍÕ»µØµã֮ǰ£¬Ò»¶¨ÒªË¼Á¿ºÃËùÓеÄΣº¦ºÍDZÔÚµÄÎÊÌâ¡£ÕâÑù²Å»ªÈ·±£×ðÁú¿Ê±´úÂëÇå¾²¿É¿¿£¬×èÖ¹±¬·¢²»ÐëÒªµÄƶÀ§¡£
ÒÔÉϾÍÊÇÔõÑùÔÚGitÉÏÐÞ¸ÄoriginµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡