"Push origin" pushes to the remote master branch
See original GitHub issueDescription
After branching off origin/master
and committing some changes to the new branch, “Push origin” pushes the commits to the remote master branch, instead of just pushing the current branch to a remote branch with the same name (as git push
would do).
Version
GitHub Desktop version: 0.6.2
OS version: macOS 10.12.5
Steps to Reproduce
git checkout -b test-push origin/master
echo 'test' > test.txt
git add test.txt
git commit -m "testing"
- In GitHub Desktop, check that “test-push” is showing as the Current Branch.
- In GitHub Desktop, click “Push origin”.
Expected behavior:
The current branch should be pushed to the remote repository, as if I’d run git push
.
Actual behavior:
! [remote rejected] test-push -> master (pre-receive hook declined)
- luckily the remote master branch is protected, otherwise it would’ve been updated!
Logs
Here’s the relevant line from the logs:
info: [ui] Executing push: git -c credential.helper= push origin test-push:master --progress
Additional information
In ~/.gitconfig
I have the following:
[push]
default = current
GitHub Desktop seems to be acting as if this is set to “upstream” rather than “current”?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
👋 @billygriffin I’ll add a +1 to this affecting me, too.
I usually have my branches track origin/master to easily see how far I am ahead/behind. But with
push.default
set tosimple
(git’s default as of 2.0), I knowgit push
would never allow pushing directly to master without me manually doing it.Recently, I was using Desktop to write some co-authored commit messages (which Desktop makes extremely friendly! 🚀 ), but I accidentally clicked the ‘Push’ button, and was shocked to see that Desktop pushed my branch’s changes to our production master. 😱
Yep, I think it’s dangerous to not respect git defaults without at least notifying/warning the user, especially so when it involves pushing to default branches like master.
🤔 I can understand this point, but I don’t agree on an all-or-nothing approach to assuming Desktop use.
In my case, I would like to use both the CLI and Desktop at the same time: I mostly create and push branches from the CLI, but Desktop is great if I need a GUI to view history or write a fancy commit message.
❓ Possibly silly question: Forgive me if I’m incorrect, but it looks like you can’t set up tracking branches from within Desktop: so, why does Desktop make assumptions on where to push if there is a tracking branch specified and it overrides the default git behavior?
IMHO, a warning that you’re about to push to the repository’s default GitHub branch would great regardless of the scenario. In this tracking branch situation, a prompt with a choice on what to do would be even better.
Sorry for the long post! 🙇♂️
No worries, thanks @billygriffin - I’ve learned to only create branches in GitHub Desktop now 😄