2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

BitbucketからGithubへ移行する場合

Last updated at Posted at 2019-01-29

初めに

移行法は非常に簡単です。

Githubのタブから以下の部分を選択肢し
スクリーンショット 2019-01-29 20.51.22.png

BitbucketのレポジトリURLをここに貼り付けしましょう。
スクリーンショット 2019-01-29 20.52.34.png

リモート先の変更

現在のリモート先を確認し

$ git remote -v  //Bitbucketのリモート先になっていると思います

Gitのレポジトリにリモート先を変更しましょう。

$ git remote set-url origin https://github.com/〜/〜.git

最後に

git pushを行うとこのようになる場合があります。

$ git push
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'c:\tmp\gittest\test'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

自分がリモートの変更をpullしてから、pushするまでの間に、他からのpushがあるなどしてリモートが変更されている状況になっているので、エラーメッセージが教えてくれているように、あなたのブランチの先端はリモートのより後ろになっています。

  • 対応方法 1) とりあえず git pull する
$ git pull

自動的にマージされて、これでpushできる状態になる

  • 対応方法 2)fetch して merge する
$ git fetch    (リモートの変更を取ってきて)
$ git merge origin/master    (マージする)
これも上と同じような結果になる。
  • 対応方法 3)fetch して rebase する
    rebase で、リモートの変更の後に自分の変更を持ってくることもできる。
$ git fetch    (リモートの変更を取ってきて)
$ git rebase origin/master
  • 対応方法 4)pull –commit や pull –rebase する
    これでも何とかなるようだが、無理してpullコマンドを使わなくてよい。

fetchとmergeとrebaseで何とかなると思います。

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?