atom-git-control icon indicating copy to clipboard operation
atom-git-control copied to clipboard

when pushing new branch and this branch does not exist in origin yet

Open vm06007 opened this issue 9 years ago • 3 comments

when pushing new branch and this branch does not exist in origin yet Im getting this error:

fatal: The current branch has no upstream branch.To push the current branch and set the remote as upstream, use git push --set-upstream origin branch_name

I believe this is because when I click on the push dialog there is option saying "push upstream", but when this is executed the command line says: git -c push.default=simple push

I think it should say git -c push.default=upstream push

vm06007 avatar May 27 '15 11:05 vm06007

Yes that seems like a reasonable change. I looked it up myself and the way you suggested it seems to be best (especially since the option is already called upstream :P ):

push.default

Defines the action git push should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line. Possible values are:

   nothing - do not push anything.

  matching - push all branches having the same name in both ends. This is for those who prepare all the branches into a publishable shape and then push them out with a single command. It is not appropriate for pushing into a repository shared by multiple users, since locally stalled branches will attempt a non-fast forward push if other users updated the branch.

   upstream - push the current branch to its upstream branch. With this, git push will update the same remote ref as the one which is merged by git pull, making push and pull symmetrical.

   simple - like upstream, but refuses to push if the upstream branch’s name is different from the local one. This is the safest option and is well-suited for beginners. It will become the default in Git 2.0.

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

from the git configuration documentation

Thanks for reporting ! :+1:

MarcelMue avatar May 28 '15 18:05 MarcelMue

also I think its correct when push set as default the same branch on origin, instead to do a git push

Example

If I mark as current the my-new-feature branch, on the dialog show

From: branch my-new-feature
To: origin/my-new-feature

Also allow type manually the branch name, this allows change to custom name

Then when the push occurs do

git push origin my-new-feature

rkmax avatar Jul 19 '15 21:07 rkmax

i used git push -u origin $(git rev-parse --abbrev-ref HEAD) in the past.

the current branch should be the default to push to!

davidak avatar Jul 23 '16 11:07 davidak