Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9162139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:08:29+00:00 2026-06-17T14:08:29+00:00

I like to use simply git push to push (only) the current branch to

  • 0

I like to use simply git push to push (only) the current branch to the configured upstream. For that I set git config push.default upstream which does exactly the right thing.

Now I tried to set up a a suitable remote for Gerrit, which automatically pushes to refs/for/*.

The idea was doing it this way:

[remote "gerrit"]
        url = ssh://host:port/repo
        push = refs/heads/*:refs/for/*

I would like to type git push gerrit and expect git to push only the current branch to the correct ref.

Unfortunately now git tries to push all local branches to Gerrit. – Is there any way to tell git to push only the current branch like with the push.default above?

Update:

  • Git push can only use a single refspec.
  • If an explicit refspec is given on the command line this one is used.
  • If none is given on the command line, the one defined with the remote is used.
  • If none is given with the remote, too, only then push.default is considered.

For Gerrit I need a refspec like ‘branch:refs/for/branch’ with branch being the current branch.

Question:

  • Is there an explicit refspec equivalent to what push.default=upstream is doing?
  • Is there a way to configure git to make a plain git push automatically push to the correct refs/for ref?

Currently the best way I found is wrapping everything in a separate script like suggested here. But I am still not convinced that it is not possible with just a suitable refspec.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:08:29+00:00Added an answer on June 17, 2026 at 2:08 pm

    According to the source, Git currently implements push.default = upstream by generating an explicit refspec containing explicit names.

    Seems like there is currently no way to specify that behavior by a single generic refspec, and some script (like suggested here) which builds an explicit refspec is the only way for now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, whenever I create a file that I'd like Git to track I simply
I like to use a simple Git workflow for static web sites but I
I have an array of Integers in Java, I would like use only a
I use git add -p to stage my changes. What I'd like to be
I want a git command that simply outputs the SHA of an arbitrary object
I'm creating a simple Java wrapper for git executable, that I want to use
I'd like to have a Git setup something like below. Developer 1 --push--> -->
I'd like to use git rebase so as to cleanly merge a feature in
I'm using git, and I'd like to be able to create a commit which
I like to use git add --patch (and more recently, git add -i) to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.