私は、上流のブランチのないリモートのリポジトリ(例えばGitHub)にプッシュするときにエラーを防ぐためのBash関数を持っています。おそらくあなたは、このエラーに精通している:git config push.default currentに切り替えることの意義は何ですか?
$ git checkout -b test
$ git push
fatal: The current branch test has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin test
、その修正私がやっていることはgit push
への呼び出しを傍受し、ノー上流分岐に関連するエラーを取得していますかどうかを確認します。そのエラーの場合は、上記のコマンドをコピー&ペーストするのではなく、私の端末で自動的に実行されます。
あなたが興味がある場合、これはコードです: https://github.com/arturoherrero/dotfiles/blob/6f517a0b7287ac61174dfd2b6c9ee5bf9a9c2e96/system/git.sh#L22-L34
私の現在のGitの設定がpush.default simple
ですが、今日、私はちょうど私が削除(同じ動作を達成するためにpush.default current
を使用することができますことに気付きました私のカスタムコード)。
Ref。 https://www.kernel.org/pub/software/scm/git/docs/git-config.html
current - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.
simple - in centralized workflow, work like upstream with an added safety to refuse to push if the upstream branch’s name is different from the local one.
When pushing to a remote that is different from the remote you normally pull from, work as current. This is the safest option and is suited for beginners.
This mode has become the default in Git 2.0.
ので、git config push.default current
への切り替えの意味は何ですか? Gitの動作が異なるため、問題が発生する可能性のあるシナリオをいくつか理解したいと思います。