Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

"simple" vs "current" push.default in git for decentralized workflow

Functionally speaking, in a decentralized workflow, I don't see the difference between simple and current options for push.default config setting.

current will push the current branch to an identically named branch on the specified remote. simple will effectively do the same thing as well for both the tracked and any untracked remotes for the current branch (it enforces identical branch names in both cases).

Can someone explain any important differences between the two for decentralized workflows that I am missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The difference is that with simple, git push (without passing a refspec) will fail if the current branch isn't tracking a remote upstream branch (even if a branch with the same name exists on the remote):

$ git checkout -b foo
Switched to a new branch 'foo'

$ git config push.default simple
$ git push
fatal: The current branch foo has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin foo

On the other hand, current doesn't care about whether or not the current branch tracks an upstream, it just wants to push to any branch that has the same name:

$ git config push.default current
$ git push
Total 0 (delta 0), reused 0 (delta 0)
To /Documents/GitHub/bare
 * [new branch]      foo-> foo

The Documentation

From the Git configuration documentation:

  • upstream - push the current branch to its upstream branch...

  • simple - like upstream, but refuses to push if the upstream branch’s name is different from the local one...

  • current - push the current branch to a branch of the same name.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...