LoginSignup
6
8

More than 5 years have passed since last update.

Bitbucketに新規リポジトリを作成後、既存の作業ディレクトリと紐付ける

Last updated at Posted at 2017-01-21

既存の作業ディレクトリと新規作成したBitbucketのリポジトリを紐つけたいことがあったので、その時の対応メモです。

環境:
- macOS Sierra
- git 2.8.2

Bitbucketで新規にリポジトリを作成すると、下記のようが画面がでてきます。
outerbridge   myrepo — Bitbucket.png

で、これを鵜呑みにすると以下のようなエラーが、、

$ cd /path/to/my/repo
$ git remote add origin https://outerbridge@bitbucket.org/outerbridge/myrepo.git
fatal: Not a git repository (or any of the parent directories): .git

そもそも、リポジトリがないからエラーになってるようです。
ということで、"git init"してから再度トライ。

$ cd /path/to/my/repo
$ git init // これ大事
$ git remote add origin https://outerbridge@bitbucket.org/outerbridge/myrepo.git
$ git add .
$ git commit -m "initial commit"
$ git branch // push前に、念のため masterブランチができてるか確認
* master
$ git push origin master

これで、紐付けが完了。

6
8
0

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
6
8