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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:13:00+00:00 2026-06-02T05:13:00+00:00

There is a Git repository on a server that my colleague and I both

  • 0

There is a Git repository on a server that my colleague and I both push to and pull from. It works fine as long as we pull before committing.

However, if he has pushed to the master branch, and in the mean time I have made a local commit, when I try to pull I get this:

! [rejected]        master    -> master  (non-fast-forward)

But I know that there should be no conflict.

The way I get around it is by pulling into a new temporary branch and then merging that into my master like this:

% git pull origin master:temp
From ssh://example.com/home/my/remote/repo
 * [new branch]      master    -> temp
Already up-to-date.
% git merge temp
Already up-to-date.
% git push origin master:master

Notice that Git acts like I’m not doing anything, but really I have shaken it into submission.

Recently I realized that instead of trying to to “convince” Git that it’s OK for me to pull. I can just pretend that I haven’t committed yet with git reset --soft HEAD^ and git stash and then do the pull and commit on top of that.

What might be causing this strangely finicky behavior?

I was able to reproduce this problem all on my local machine. Here’s what I did:

First I made the first “local” repository and added a file.

% cd
% mkdir local-1
% cd local-1/
% mkdir website
% cd website/
% git init
Initialized empty Git repository in /Users/jason/local-1/website/.git/
% touch file
% git add .
% git commit -m 'added file'
[master (root-commit) 6d4b322] added file
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file

Then I made the “remote” repository.

% cd
% mkdir remote
% cd remote
% mkdir website.git
% cd website.git/
% git init --bare
Initialized empty Git repository in /Users/jason/remote/website.git/

Then I went back to the local, created a ref and pushed to the remote.

% cd ~/local-1/website/
% git remote add web ~/remote/website.git
% git push web +master:refs/heads/master
Counting objects: 3, done.
Writing objects: 100% (3/3), 207 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /Users/jason/remote/website.git
 * [new branch]      master -> master

After that I cloned the remote into a second local.

% cd
% mkdir local-2
% cd local-2
% git clone ~/remote/website.git
Cloning into website...
done.

Then I created a ref to the remote from the second local and pushed (this is where I am creating the problem I think).

% cd website/
% git remote add web ~/remote/website.git
% git push web +master:refs/heads/master
Everything up-to-date

Then I made a change to local-2, committed, and pushed.

% touch another
% git add .
% git commit -m 'added another'
[master be91180] added another
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 another
% git push web
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 238 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /Users/jason/remote/website.git
   6d4b322..be91180  master -> master

Finally, I made a different change to local-1, committed, and tried to push.

% cd ~/local-1/website/
% touch something
% git add .
% git commit -m 'added something'
[master 3984529] added something
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 something
% git push web
To /Users/jason/remote/website.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '/Users/jason/remote/website.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.

Blast! How about a pull?

% git pull web master:master
From /Users/jason/remote/website
 ! [rejected]        master     -> master  (non-fast-forward)

OK, so there’s the problem. How do I fix it?

  • 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-02T05:13:03+00:00Added an answer on June 2, 2026 at 5:13 am

    You probably meant to do:

    git pull web master
    

    Using master:master is trying to directly update you local master branch in the fetch stage of the pull which is causing the non fast-forward error.

    If you’re on a branch that is set up to track web/master then you only need git pull web and this will update your remote tracking branches as well.

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

Sidebar

Related Questions

Is there any way to git pull all folders in the repository but one?
I have a server that contains a central git repository and one of my
I would like to access (clone/push/pull) a private (via ssh) git repository while behind
Is there a way to make an svn-checkout from a git repository? The problem
I know that normally there are no problems using Git from different OSs to
I have a Git repository on my local machine that I cloned from my
I am using a bare git repository on a server for backup, and push
Is there a way to set up a local git repository that would be
Is there a Python way without using a subprocess to clone a git repository?
In git, there is a command 'git bundle' which bundles a git repository into

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.