tags:

views:

134

answers:

3

Hi

I have got my repo into a bit of a state and want to be able to work my way out of it

The repo looks a bit like this (A1, B1, C1 etc are obviously commits)

                  A1 ---- A2 ---- A3 ---- A4 ---- A5 ---- A6 ---- A7 ---- A8
                                                                  /
(from a remote repo)  B1 ---- B2 ---------------------------------  
                              | \
                              \  C1 ---------------------------------C2 
                               \                                     /
                                D1 --- D2 --- D3 --- D4 --- D5 --- D6

Ideally I'd like to be able to remove all the revisions (with rebase?) on the B, C and D lines (I'm loathed to say branches simply because there are now no local branches on these lines except ref branches to the remote repo) and try to merge in the remote repo again, perhaps in a better way.

I'd be grateful of any suggestions as to how to get rid of all these commits. Could I ask that any answers use revision SHA1s rather than branch names. I thought that somehow I'd be able to revert the merge into A7 but can't quite work out how to do it

I hope that is sufficient information. Many thx

Simon

+1  A: 

By tidy, I'll assume you mean linearize your changes.

You should be able to do something like:

git rebase A B
git rebase 'A C
git rebase ''A D

A B C and D are representing the commit/refs involved in rebasing. Actually passing A B C and/or D to rebase will probably do nothing. You should do something like this:

git rebase master branchname

Does that help?

xyld
Thx I tried git rebase A7-SHA1 B1-SHA1 and nothing appears to change. Is that what you meant?
Simon Woods
Sorry didn't make myself clear! The command I entered was git rebase c96769ef2f 557b29ecc0
Simon Woods
Rebase is an operation on branches. Just create local branches at the commits you want to play with, do the operations, push in what you want to, and then delete those branches.
Novelocrat
Think it works on SHA1s as well, doesn't it? It is obviously doing something with the intermediate commits when I execute the command. I'll add a fuller reply ... thx for responding.
Simon Woods
+1  A: 

Rebasing the branches is most likely what you want to do, as xyld suggested.

Before you do that, I would recommend reading up on the rebase command from chapter 3 of the Pro Git book. It should help explain how the process works and the "gotchas" you need to be aware of. (For example, you should never rebase commits which you have already pushed to the public repository, or that would screw it up for everyone else... but it doesn't sound like that's the case here.)

ewall
Thx vm. It is an excellent resource.
Simon Woods
A: 

When I execute

git rebase -f 557b29ecc0ec c96769ef2f

It is obviously performing the rebase. However, it reports

Falling back to patching base and 3-way merge...
error: Your local changes to 'Client/WebDataEntry/temp.txt' would be overwritten by 
merge.  Aborting.
Failed to merge in the changes.
Patch failed at 0004 Initial Source Load

I have previously added/committed any changes, so am unsure why it should report this, other than there is some sort of cyclical situation or situation in which is it unable to resolve a conflict automatically since it finishes with

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

So I try to run the rebase interactively

git rebase -i 557b29ecc0ec c96769ef2f

but I get the error

Invalid branchname: c96769ef2f

I should perhaps add that it may well be that my thinking/understanding is flawed. I was hoping that since there is no common ancestor between A1 and B1 if I rebase B1 (or any of it's subsequent commits) onto A1 it will effectively blow the B1/C1/D1 lines away.

Thx again

Simon Woods