Help us understand the problem. What is going on with this article?

[Git] リポジトリを GitHub(Public) から Bitbucket(private) に移行する方法、 remote を増やしたり減らしたりして管理を柔軟にする方法

More than 5 years have passed since last update.

状況

細々とプロジェクトをすすめていて、そろそろコードを非公開にしなくちゃいけないところに来たけれど、お金がないって状況になり、無料でプライベートリポジトリを使える Bitbucket を利用することにしました。

やること

$ git remote set-url origin git@bitbucket.org/watashi/project.git
$ git push origin master --force

origin の上書きということですかね。
一応 config をチェックしました。

$ vim {PROJECT_ROOT}/.git/config
---
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@bitbucket.org/watashi/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

確かに remote の origin の url が bitbucketのものになっています。

remote の追加

今後、githubに戻すかもしれないので、一応 github も残しておきたい。

$ git remote add github git@github.com:watashi/project.git

一応 config を見てみる

$ vim {PROJECT_ROOT}/.git/config
---
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[branch "master"]
[remote "github"]
    url = git@github.com:su3/letterpress_dev.git
    fetch = +refs/heads/*:refs/remotes/github/*
[remote "origin"]
    url = git@bitbucket.org/watashi/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*

remote の確認

登録された remote は以下のコマンドで確認できます。

$ git remote -v
---
github  git@github.com:watashi/project.git (fetch)
github  git@github.com:watashi/project.git (push)
origin  git@bitbucket.org/watashi/project.git (fetch)
origin  git@bitbucket.org/watashi/project.git (push)

remote の削除

やっぱいいや、いらないかな...って時は。

$ git remote rm github

ref) http://bayashi.net/diary/2012/0714

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした