綾小路龍之介の素人思考

[git] レポジトリのURLを変更する。

gitのリモートレポジトリのURLが変わったり、多数のレポジトリを登録しておきたい場合がある。

pullすると最新の状態といわれるが、これはレポジトリが存在しない場合可能性がある。例えば、up-to-dateといわれたレポジトリのURLをwgetで叩くと404 notfoundになる。

$ git pull
Already up-to-date.
$ git remote show
origin
$ git remote show origin
* remote origin
  Fetch URL: http://github.com/hannahbrian/webservice-google-reader.git
  Push  URL: http://github.com/hannahbrian/webservice-google-reader.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
$ wget --no-check-certificate http://github.com/hannahbrian/webservice-google-reader.git
--2011-03-20 20:19:27--  http://github.com/hannahbrian/webservice-google-reader.git
Resolving github.com... 207.97.227.239
Connecting to github.com|207.97.227.239|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/hannahbrian/webservice-google-reader.git [following]
--2011-03-20 20:19:27--  https://github.com/hannahbrian/webservice-google-reader.git
Connecting to github.com|207.97.227.239|:443... connected.
WARNING: certificate common name “*.github.com” doesn’t match requested host name “github.com”.
HTTP request sent, awaiting response... 404 Not Found
2011-03-20 20:19:29 ERROR 404: Not Found.

このようなレポジトリURLを削除して新しいURLを登録する。

$ git remote add origin https://github.com/gray/webservice-google-reader.git
fatal: remote origin already exists.
$ git remote rm origin
$ git remote add origin https://github.com/gray/webservice-google-reader.git
$ git pull
remote: Counting objects: 211, done.
remote: Compressing objects: 100% (96/96), done.
remote: Total 187 (delta 74), reused 152 (delta 53)
Receiving objects: 100% (187/187), 21.33 KiB, done.
Resolving deltas: 100% (74/74), completed with 6 local objects.
From https://github.com/gray/webservice-google-reader
 * [new branch]      master     -> origin/master
 * [new tag]         0.10       -> 0.10
 * [new tag]         0.15       -> 0.15
From https://github.com/gray/webservice-google-reader
 * [new tag]         0.12       -> 0.12
 * [new tag]         0.13       -> 0.13
 * [new tag]         0.14       -> 0.14
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "master"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.
$ git pull origin master
From https://github.com/gray/webservice-google-reader
 * branch            master     -> FETCH_HEAD
Auto-merging lib/WebService/Google/Reader.pm
CONFLICT (content): Merge conflict in lib/WebService/Google/Reader.pm
Auto-merging lib/WebService/Google/Reader/Constants.pm
Automatic merge failed; fix conflicts and then commit the result.

リファレンス

  1. git remote add - Google 検索
  2. [Git] Git コマンドメモ - それはBlog

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2009-10-24T20:33:38+09:00
  2. Modified: 2009-10-24T20:33:38+09:00
  3. Generated: 2017-08-02T23:09:15+09:00