61

I am getting this message:

 First, rewinding head to replay your work on top of it...

each time I do a git pull --rebase origin <branch>, however I would like to discard all my work that may be replayed on top of it.. Basically I would like to rebase only the origin branch without my work on top of it. How can I clean those commits that comes up wrongly all times I try to pull rebase? Again, my goal is just pull rebase the exact snapshot of the origin branch without my work on top of it.

starball
  • 20,030
  • 7
  • 43
  • 238
Rollerball
  • 12,618
  • 23
  • 92
  • 161
  • 3
    This isn't 100% clear to me; "rebase" effectively means "apply my commits on top of the commits taken from elsewhere". So it sounds like you don't want rebasing at all. Can you draw some commit graphs to show what you want to achieve? – Oliver Charlesworth Mar 11 '14 at 08:28
  • @OliCharlesworth the thing is that there is no work on top of it... it's like some commits have been cached and I cannot get rid of them. They just appear only when I pull rebase – Rollerball Mar 11 '14 at 08:38
  • 2
    You're saying that you have no local commits (i.e. `` and `origin/` are at the same place in your local repo) but that you get some unexpected behaviour when you `pull --rebase`? Can you add the *complete* output of `git pull --rebase` to your question? – Oliver Charlesworth Mar 11 '14 at 08:40
  • @Rollerball Did aragaer's answer help solve your problem? – The Unknown Dev Aug 29 '14 at 14:57

2 Answers2

100

git fetch origin; git reset --hard origin/<branch>

aragaer
  • 17,238
  • 6
  • 47
  • 49
1

I have 3 branchs:main,feat-dev,func。(feat-dev from main,func from feat-dev)

I use these step:

  1. on func, git rebase origin/feat-dev; git push --force;
  2. on feat-dev, git rebase origin/main; git push --force;
  3. on func, git rebase origin/feat-dev.

git tell me same messages: "First, rewinding head to replay your work on top of it..."

On func, I just use

git push --force

Then everything goes fine.