LoginSignup
106
103

ローカルgitリポジトリでリモートのリポジトリURL確認方法

Last updated at Posted at 2017-03-24

ローカルにクローンしたリポジトリのリモートURLを確認する方法はいくつあります。

リポジトリ例: 
$ git clone git@github.com:ruby/ruby.git ruby
$ cd ruby

方法1

$ git config --get remote.origin.url
git@github.com:ruby/ruby.git

方法2

$ git remote -v
origin  git@github.com:ruby/ruby.git (fetch)
origin  git@github.com:ruby/ruby.git (push)

方法3

$ git remote show -n origin
* remote origin
  Fetch URL: git@github.com:ruby/ruby.git
  Push  URL: git@github.com:ruby/ruby.git
  HEAD branch: (not queried)
  Local ref configured for 'git push' (status not queried):
    (matching) pushes to (matching)

方法4

$ git remote show origin
* remote origin
  Fetch URL: git@github.com:ruby/ruby.git
  Push  URL: git@github.com:ruby/ruby.git
  HEAD branch: trunk
  Remote branches:
    ruby_1_3   new (next fetch will store in remotes/origin)
    ruby_1_4   new (next fetch will store in remotes/origin)
....

方法5

$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:ruby/ruby.git

方法6

$ git config -l
...
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@github.com:ruby/ruby.git

方法7

$ git remote get-url origin

...
git@github.com:ruby/ruby.git


なお、git helpを活用すれば、何でも調査できる。例

```bash
$ git remote show --help
usage: git remote show [<options>] <name>

    -n                    do not query remotes

参照

106
103
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
106
103