I have these commits: (TL;DR below...)
A <- B <- C
These are on top of colleague's commits:
U <- V <- W <- A <- B <- C
Now the colleague rebased his branch to new master
, pushed to github repo which updated the PR then added a commit, pushed to github repo, then I resolved the conflicts on github and commited to the branch on github, then the colleague squashed two of the commits and added another one, and then our team lead chimed in and starts editing with github editor. So it ends up like this: [1]
X' <- A'' <- U -> C <- W -> B ---> L --> O --> O
<--- master' / | / <------ master
G ---------> M --/ \- abyssmal' <-- P --/
In other words, the original branches got quite irrelevant and the new state of things has very little to do with the original state. I think no git command manipulating the branches can really target this using . I only want to take the remnants of my work (in the form of few successive commits) and try to adapt it to today's codebase.
I am writing the story because typically people try to offer solutions to my underlying problem, which is great, but I would prefer to know this particular operation, if github has means to do it. Also, I am stating that there are no branches because whenever few people work on one branch, things get messy quickly and branches loose any sense. Lack of discipline or using Git in a wrong way. I know. Not solving that, I will be happy with the solution to this.
All that matters to me is:
TL;DR:
How to copy any chain of commits (provided they are chained) to some other commit, in one command? I.e. I have:
...hicSuntLeones <- myCommitA <- myCommitB <- myCommitC <- whatever...
I want a super-simple command:
git copyCommits --since myCommitA --until myCommitC --putThemTo terraInrecognita
I want it to end up like this:
...terraIncognita <- myCommitA' <- myCommitB' <- myCommitC'
With intermediate conflicts resolving of course.
I was looking at git rebase --onto
, but that seems to work with different logic that I need - it would let me "divorce" another branch, but I don't have that branch. If I understand it correctly.
I am looking around stack overflow and web, but still can't find. The git answers tend to explain how git works, how git rebase works, what is the contrast of the design philosophy of git with the philosophy of a more traditional source control tool like svn, how SCM works in general, how the relationships with parents are important and other things. I don't want to sound arrogant, but I am only looking for a command to do the above. Is there any? Thanks :)
[1] It's not really that bad, just normal daily chaos. But still it makes this approach easier than thinking in branches.
Edit: Not providing an answer: Difference between 'rebase master' and 'rebase --onto master' from a branch derived from a branch of master This referenced duplicate, also referenced in the question, does not answer my question. It has lenghty answers on how git works, how branches work, but not really giving the answer to my question. Maybe it's implied there but not given.