0

I usually use git push origin HEAD on the command line when I want to push my local branch to GitHub for the first time. That way I don't have to type the branch name. What is the equivalent in Magit?

1

Magit does provide the exact equivalent. Instead it fully embraces both the upstream and the push-remote. When both of these remotes are configured for the current branch, then Magit can show logs in the status buffer which show which commits are in the current branch but not in the upstream and vice-versa, and for the push-remote it can do the same.

The upstream of a branch is usually set when the branch is created and the push-remote is usually set when you first use the "push to push-remote" command. To do so type P p, select a remote, and confirm with RET. The current branch will then be pushed to that remote to a branch with the same name as the local branch. For subsequent pushes you only have to type P p. https://magit.vc/manual/magit/The-two-remotes.html For more information about the upstream and the push-remote see the node about the two remotes.

  • Pressing TAB when prompted for a remote sets "origin", which does what I want, even when the remote doesn't exist yet. Thanks! – js. Sep 1 '16 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.