8

Gitを誤用しているかどうか、または構成に問題があるかどうかはわかりません。

GithubリポジトリをマシンAとBに複製してから、マシンAIで次のようにします。

git checkout -b branchA
// make edits
git add .
git commit -am "initial"
git push

次に、マシンBIで次のことを行います。

git pull
git checkout branchA
// make edits
git commit -am "edits"
git push

マシンAIで次に行います:

git pull

しかしそれは言う:

There is no tracking information for the current branch

だから私はしなければならない:

git branch --set-upstream branchA origin/branchA

元々origin/branchAに問題なくプッシュされたのに、なぜアップストリームを設定する必要があるのですか?

私はmsygit1.8を使用しています。Windowsの場合。

PSpullマシンBで実行すると、新しいブランチbranchAがデフォルトで追跡されないのはなぜですか?git branch表示されません(ただし、で表示され-rます)。すべての新しいリモートブランチをデフォルトで追跡するようにできますか?pull?

4

1 に答える 1

13

git config push.defaultは何も返さないので、つまり、「git 1.8.0.msysgit.0」では、「一致する」ブランチを表すrefspec' 'をgit push意味します。git push origin ::

branchAここでは、リモート側でマッチングを作成します。

しかし、それはそれをリモート追跡ブランチにしません。
つまり、branch.branchA.merge何にも設定されていません。
これがgitプルが失敗する理由です。ローカルにマージすることになっているリモートブランチがわかりませんbranchA


最初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

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)

したがって、Git2.0では、そのgitプッシュは失敗します。
プッシュbranchAする唯一の方法は、そのアップストリームブランチを(同じ名前を使用して)明示的に設定することです。

git push -u origin branchA
于 2012-12-14T21:21:01.993 に答える