Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: First rewinding head to replay

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. Thanks in advance.

like image 305
Rollerball Avatar asked Mar 11 '14 08:03

Rollerball


People also ask

What is the first rewinding head to replay your work on top?

Note the “rewinding head to replay your work on top of it…”. It means that your commits are rebased onto current remote HEAD . If you want to merge a feature branch it might be wiser to actually merge your commits (thus having a single point of integration of two distinct branches).

Is it safe to use git pull -- rebase?

I recommend to use git pull --rebase only if you know you forgot to push your commits before someone else does the same. If you did not commit anything, but your working space is not clean, just git stash before to git pull .


2 Answers

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

like image 200
aragaer Avatar answered Sep 20 '22 17:09

aragaer


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.

like image 39
我要改名叫嘟嘟 Avatar answered Sep 17 '22 17:09

我要改名叫嘟嘟