1
$sudo git clone sample.git
Cloning into 'sample'...
warning: You appear to have cloned an empty repository.
done.
$ cd sample
$ echo "hello world" > readme
$ git add readme
$ git checkout -b a
Switched to a new branch 'a'
$ git branch
$ git checkout master
error: pathspec 'master' did not match any file(s) known to git.
$ git checkout a
error: pathspec 'a' did not match any file(s) known to git.
$ git checkout -b b
Switched to a new branch 'b'
$ git branch
$ git commit -am .
[b (root-commit) 12b8434] .
1 file changed, 1 insertion(+)
create mode 100644 go
$ git branch
* b
$ git checkout a
error: pathspec 'a' did not match any file(s) known to git.
$ git checkout -b a
Switched to a new branch 'a'
$ git branch
* a
b
私の最初のcheckout -b a
で何が問題だったのですが、なぜブランチが作成されなかったのですか?チェックアウト-bは2回目の試行後にのみ動作するのはなぜですか?
あなたは数秒で私を打ち負かす:)ええ、gitはリポジトリにコミットがないと面白いように振舞う傾向がある – quetzalcoatl
この動作は混乱します。私はGitを新しいバージョンにアップデートした後に見つけました。これで 'git init'は偽のマスターブランチを作成します。私はそれをバグと見なします。 – ElpieKay
誰かがそれをバグとみなしているようです。私の例は 'git 2.0.4'です。 – AnoE