0

I saw some similar questions but there are all about git push ,not git pull.

In order keep my local branch a_branch updated with the remote master branch.

I run:

git pull origin HEAD:master  

But I received:

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

Then I tried:

git fetch origin master

git pull origin HEAD:master

Still same error.

Any friend can help?

William
  • 3,724
  • 9
  • 43
  • 76
  • Doing a fetch before a pull has no effect. – Guildenstern Aug 30 '23 at 23:04
  • @Guildenstern then can you let me know ,what should I do ? – William Aug 30 '23 at 23:06
  • 1
    Have you done any changes on the branch before you last pulled from it? That would cause this error. If you only pull into it (and never modify it yourself) then you will never get this error. – Guildenstern Aug 30 '23 at 23:08
  • @Guildenstern yes ,my team member did some changes before I pulled from it – William Aug 30 '23 at 23:10
  • Were those changes from your team member done on the system you're using, or were they done elsewhere and available to you through `origin`? – Jim Redmond Aug 30 '23 at 23:12
  • What are the values of `git config pull.ff` and `git config merge.ff`? `pull.ff` overwrites `merge.ff` when pulling. If the value is `only`, it prevents a non-fast-forward merge. But when I test it, the error message is different. – ElpieKay Aug 31 '23 at 01:49
  • Show the output of `git config remote.origin.fetch`. – j6t Aug 31 '23 at 06:17
  • Your local branch has diverged from the remote branch (hence non-fast-forward). Run `gitk --all &` to get a visual presentation your history. I recently [wrote an answer](https://stackoverflow.com/a/76984332/23118) related to this. – hlovdal Aug 31 '23 at 07:02

0 Answers0