开发者

Git - tidying up a repo

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


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?


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.)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜