このブログは、旧・はてなダイアリー「檜山正幸のキマイラ飼育記 メモ編」(http://d.hatena.ne.jp/m-hiyama-memo/)のデータを移行・保存したものであり、今後(2019年1月以降)更新の予定はありません。

今後の更新は、新しいブログ http://m-hiyama-memo.hatenablog.com/ で行います。

magitによるリポジトリ生成とbitbucketへのプッシュ

  1. M-x magit-init する。Magitバッファには、"In the beginning there was darkness" というメッセージ。
  2. MagitバッファにUntracked filesがリストされているので、適当に選んで、s (staging)する。Staged changesにステージされたファイルが表示される。
  3. u (unstage)でステージングエリアから外せるのがとても便利。コミット前の確認が楽。
  4. Magitバッファから c 、ヘルプ画面が出るがここでさらに c。
  5. コミットメッセージのバッファが出る。ここでコミットメッセージを書く。
  6. C-c C-c でコミットが実行される。
  7. Magitバッファも変わる。

bitbucketにもリポジトリを作る。これはブラウザから手動。[追記]2016-02 現在は https://bitbucket.org/ でログイン→ Repositories → Create Repository[/追記]

  1. Create → Create a new repository で必要事項を記入。
  2. "Already have a Git repository on your computer? Let's push it up to Bitbucket." に指示が出る。
  3. その指示は:
    1. cd /path/to/my/repo
    2. git remote add origin https://m_hiyama@bitbucket.org/m_hiyama/repo-name.git
    3. git push -u origin --all # pushes up the repo and its refs for the first time
    4. git push -u origin --tags # pushes up any tags

Magitでは、

  1. リモート名がorigin、URLは https://m_hiyama@bitbucket.org/m_hiyama/repo-name.git、これは参照できるようにしておく。
  2. M-x magit-remote-add 、リモート名とURLを対話的に入れる。
  3. Magitバッファで y でブランチをビューできる。その他のブランチ操作は、Magitバッファで b。
  4. Magitバッファで P (大文字)でプッシュ。
  5. その後で -uP

ここで次のエラー:

Pushing to master
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

コンソールからやってみたら、特に問題なし。


$ git push -u origin --all
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 609 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://m_hiyama@bitbucket.org/m_hiyama/repo-name.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

$

なんかの勘違いか? その後はmagitからでもうまくいく。プッシュはPね。

[追記]分かった。P -u P の対話的プロンプトに対して、origin/master と入れるのだ。[/追記]magit操作 - 檜山正幸のキマイラ飼育記 メモ編