このワークフローの何が問題なのか説明していただけますか?
$ git init --bare bare
Initialized empty Git repository in /work/fun/git_experiments/bare/
$ git clone bare alice
Cloning into alice...
done.
warning: You appear to have cloned an empty repository.
$ cd alice/
$ touch a
$ git add a
$ git commit -m "Added a"
[master (root-commit) 70d52d4] Added a
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '/work/fun/git_experiments/bare'
git push
クローン元のリポジトリに常にプッシュされるわけではありませんか?
ベストアンサー1
はい、問題は「bare」にコミットがないことです。リポジトリを (bare、alice) の順序で作成した場合、これは最初のコミットのみの問題です。次の操作を試してください。
git push --set-upstream origin master
これは最初の 1 回のみ必要です。その後は正常に動作するはずです。
Chris Johnsen が指摘したように、push.default がカスタマイズされていれば、この問題は発生しません。私は、upstream/tracking を好みます。