magitによるリポジトリ生成とbitbucketへのプッシュ
- M-x magit-init する。Magitバッファには、"In the beginning there was darkness" というメッセージ。
- MagitバッファにUntracked filesがリストされているので、適当に選んで、s (staging)する。Staged changesにステージされたファイルが表示される。
- u (unstage)でステージングエリアから外せるのがとても便利。コミット前の確認が楽。
- Magitバッファから c 、ヘルプ画面が出るがここでさらに c。
- コミットメッセージのバッファが出る。ここでコミットメッセージを書く。
- C-c C-c でコミットが実行される。
- Magitバッファも変わる。
bitbucketにもリポジトリを作る。これはブラウザから手動。[追記]2016-02 現在は https://bitbucket.org/ でログイン→ Repositories → Create Repository[/追記]
- Create → Create a new repository で必要事項を記入。
- "Already have a Git repository on your computer? Let's push it up to Bitbucket." に指示が出る。
- その指示は:
- cd /path/to/my/repo
- git remote add origin https://m_hiyama@bitbucket.org/m_hiyama/repo-name.git
- git push -u origin --all # pushes up the repo and its refs for the first time
- git push -u origin --tags # pushes up any tags
Magitでは、
- リモート名がorigin、URLは https://m_hiyama@bitbucket.org/m_hiyama/repo-name.git、これは参照できるようにしておく。
- M-x magit-remote-add 、リモート名とURLを対話的に入れる。
- Magitバッファで y でブランチをビューできる。その他のブランチ操作は、Magitバッファで b。
- Magitバッファで P (大文字)でプッシュ。
- その後で -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操作 - 檜山正幸のキマイラ飼育記 メモ編