Hexoの作業フォルダはWindows領域のDropboxフォルダに置き、他のPCとも同期をとっている。
これでソースを消失してしまう危険はかなり低いと思うが、Dropboxと同期する際、結構時間がかかってしまう。
普段はDropboxを起動しておらず時々立ち上げる、という形をとっているせいもあるかもしれない。

Bitbucketにソースを置いたらpushするのはそれほど時間は掛からないだろうし、過去の履歴も残ってくれてやはり便利だろうと思い、HexoのソースをBitbucketに置くことにした。

OctopressのソースをBitbucketに置いた時と同様、Bitbucketにhexoという名前のリポジトリを作り、

$ git remote add bitbucket git@bitbucket.org:ユーザー名/hexo.git
$ git push -u bitbucket source

とやったが、エラーになる。

新規リポジトリを作成後に表示されたRepository setupの指示に倣い、

$ git init
$ git remote add bitbucket git@bitbucket.org:ユーザー名/hexo.git
$ echo "ユーザー名" >> contributors.txt
$ git add contributors.txt
$ git commit -m 'Initial commit with contributors'
$ git push -u bitbucket source

としても、やはり

error: src refspec source does not match any.
error: failed to push some refs to 'git@bitbucket.org:ユーザー名/hexo.git'

とエラーになる。

pushするbranchをsourceではなく、masterにしてみた。

$ git push -u bitbucket master
Counting objects: 3, done.
Writing objects: 100% (3/3), 239 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@bitbucket.org:ユーザー名/hexo.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from bitbucket.

上手く行ったようだ。

だが、その後も

$ git add .
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'contributors.txt' that are
removed from your working tree are ignored with this version of Git.

* 'git add --ignore-removal <pathspec>', which is the current default,
  ignores paths you removed from your working tree.

* 'git add --all <pathspec>' will let you also record the removals.

Run 'git status' to check the paths you removed from your working tree.

と言われたり、

$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

と言われたり。

git add .は使われなくなったのでgit add -Aにしないといけないということか?
git add .でもすんなり通る時もあるのは、状況の違いからだろうか。
(追記:そう言えば、Initial commitの時に作成されたcontributors.txtという中身が自分のユーザー名だけのファイルを、リポジトリとHexoの作業フォルダ両方から手動で削除したんだった。
これのせいだったのかもしれない。)

push.defaultもmatchingにした。

  $ git config --global push.default matching

これでようやくpush出来るようになった。

gitの仕組みがいまいちよく分からない。

表示   このエントリーをはてなブックマークに追加

Comments

2014年11月26日