On Monday, September 23, 2013 6:02:22 AM UTC+2, dexter ietf wrote:

> On Saturday, September 21, 2013 5:18:13 PM UTC+5:30, dexter ietf wrote:
>> hi,
>> i cloned  a new tree, made changes to file readme.txt
>> meantime readme.txt in the remote has changed at
>> the same location. when i do a git pull i got merge
>> conflicts, i resolved the conflicts and did a 'git commit'
So far so good. After this commit, you have a merge commit where your local 
commits joined together with the remote commits. This merge commit includes 
the fixes from the conflicts you resolved.

> now i did git rebase, 
Now why on earth would you do rebase at this point? When you want to merge 
with another branch of development, you EITHER rebase OR merge. In the 
above case you decided to pull, which means fetch & merge.

So what happens when you try rebasing a branch that you already merged? 
Well, your local commits, including the merge commit we talked about 
earlier, are temporarily removed, then the remote commits are "played back" 
first. And then your local commits are played back on top of that again. If 
you can follow that reasoning (read up on rebase if not), what happens now 

- your local commits are applied in running order
- the first commit that does not apply cleanly will create a conflict 
similar to the one you had before
- rebase will now stop, and ask you to resolve the conflicts
- if you resolve the conflicts and continue, you'll later run into your 
local merge commit, where you have to resolve conflicts that have already 
been resolved in the previous step. No doubt this will lead to more 
conflicts that have to be resolved.

If you do resolve the conflicts again and continue through with the rebase, 
you should get through it OK. However, you were on the wrong track already 
when you tried rebasing in changes that you had already merged.

I would advise you to first decide whether you want to merge or rebase, 
then have a good look at the `git reflog`, find the last state you had 
before the mess, and then `reset hard` back to this.

Do take a full copy of your git repository before doing anything more 

Maybe all of this seems intimidating and complicated, but it's a classic 
case of Git's freedom allowing you to chop of your own foot. Luckily it's 
easy to reset the foot back on again :)

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to