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 7978313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:27:37+00:00 2026-06-04T09:27:37+00:00

I have a repository on github, say testrepo. Now I’d like to set up

  • 0

I have a repository on github, say testrepo. Now I’d like to set up a local repository repo that has one branch origin-master where I want do be able to edit things from the repository.

repo/origin-master  <-------->  origin/master

The cloning works fine:

mkdir repo && cd repo && git init 
# not necessary of course:
echo "master" > master && git add master && git ci -m "master"
git remote add origin git@github.com:<username>/testrepo.git
git fetch origin
git branch --set-upstream origin-master origin/master 
git checkout origin-master
# create a new file:
echo "for origin-master" > orig-master && git add orig-master && git ci -m "orig-master"

but

git push origin 
To git@github.com:<username>/testrepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:<username>/testrepo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

How can I tell git that if I want to push to origin, I want to push the local branch origin-master to origin/master?

  • 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-04T09:27:39+00:00Added an answer on June 4, 2026 at 9:27 am

    Set your default push behavior to upstream:

    $ git config push.default upstream
    $ git push origin
    

    git push origin is the same as git push origin :, which pushes all “matching” branches by default. Your origin-master branch doesn’t match, so it tries to take the branch that does match (master) and push that to origin.

    Alternatively, you can specify the push refspecs on a per-remote basis:

    $ git config --add remote.origin.push origin-master:master
    $ git push origin
    

    See also git-push examples and git-config.

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

Sidebar

Related Questions

I have a private repository in github that has 5 collaborators.Now when the collaborators
I have a remote repository http://github.com/fernandezpablo85/Test This repo has a master branch, but it's
Is it possible to use a public repository like github and have a branch
I have ONE repository on GitHub , let's call it Repo-1 . I want
Lets say, I don't have access to github. How is my local repository useful
I have a repository on GitHub. It contains master and one branch. When I
I have repository on GitHub to which I commit regularly from my local computer.
I have a private repository on Github that I want to use. I deploy
I have one 'super' repository in GitHub which will contain several applications I would
I currently have a git repository at github that stores the packaging files for

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.