I’m creating a big feature in one of our projects, that is close to around 20 commits in my local repository. Most of them are still subject to change with rebasing, but I’d like to push the first few stable ones for review already.

In the command line, I’d do

git push origin affec75:master

(given that affec75 is a commit somewhere in my local history.)

I tried P r (explicit refspecs), specifying origin as the remote and affec75 as the refspec, but it failed. As the generated command is git push origin affec75, I tried setting affec75:master as the refspec; it succeeds, but it’s a real pain to type. Is there a shorter way to do this?

1 Answer 1

  1. Move to the commit.
  2. P o to push "another branch" (despite the description in the popup, this can also push arbitrary commits).
  3. RET confirm the default source, which should be the abbreviated commit hash. If a branch points at the commit, then the commit is the second choice.
  4. RET confirm the default target, which should be the current branch. (But only if the commit is reachable from HEAD.)
  • Thank you, I did. Commented Oct 11, 2016 at 14:03
  • Doesn't P o work for this?
    – npostavs
    Commented Oct 11, 2016 at 14:16
  • You're right. But it should be made a bit smarter by offering the appropriate branch as default choice.
    – tarsius
    Commented Oct 11, 2016 at 14:28
  • 3
    and… the feature is implemented ! It's based on P o.
    – Ehvince
    Commented Oct 11, 2016 at 21:45
  • If you incorporate it in the answer, I’ll accept it! Oh, and Kudos for the quick implementation! Commented Oct 12, 2016 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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