git pull: Not possible to fast-forward,
Asked Answered
L

3

14

could you please help me to solve my issue? Error occurs when I try to pull from "dev" branch. I browsed the solution and it says that I need to "rebase" but it didnt work out foe me.

CT+aohc@MP1GYWQA MINGW64 /c/TCO/source/RAPMD.Web.Frontend (web_feature/TCORAPD-122389-1)
$ git pull origin dev
From https://dev.azure.com/xxxx/xxxx/_git/TCO-FGP-Rapmd
 * branch                  dev        -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
Lambert answered 31/5, 2022 at 10:36 Comment(3)
Do you have local changes in the same branch? What does git status tell you?Ghostly
What did you try exactly? git rebase origin/dev? And what does "didn't work out for me" mean? Did you get any error or what happened?Inconclusive
Does this answer your question? Fatal: Not possible to fast-forward, abortingCopestone
W
31

You can follow the following steps:

  • Run git pull --rebase origin dev
  • if you face conflicts then you need to solve those conflicts and run
    • git add <file_name>/ git add .
    • git rebase --continue
  • continue second step until you solve conflicts(remeber rebase compare changes commit wise)
    • Then run git rebase --skip if needed
  • After you successfullly aplied rebase you need to force push the changes
    • Run git push --force-with-lease origin dev (safer way of force push) OR git push -f origin dev

FOR REFERENCE: https://gitexplorer.com/

Wittol answered 1/6, 2022 at 10:10 Comment(2)
be careful with rebasing, you might loose your workOreilly
@Oreilly , Yes , You just need to solve the conflict properly. Then no code will be removed.Wittol
S
26

Easiest way, This worked for me:

git fetch origin dev
git merge origin dev

Replace dev with branch_name you want to pull.

Styracaceous answered 13/10, 2022 at 10:17 Comment(4)
Fixed the issue for meDelectation
the 2 above commands are the same as git pull originOreilly
Agree @OreillyStyracaceous
Finally something that works!Tanganyika
R
3

Just add --no-rebase to your pull command e.g., git pull origin --no-rebase

This will take u to merge and a editor might open. Write :WQ and enter

you should be able to successfully pull now.

Rolo answered 21/2, 2023 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.