How to rebase an entire commit graph?
up vote
0
down vote
favorite
We have a project repository left
.
Then we created a clone repository right
from the topmost snapshot of the left
(and worked there for some weeks).
How can we merge the two graphs?
(to let the team merge between the two)
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
git tree repository branch rebase
add a comment |
up vote
0
down vote
favorite
We have a project repository left
.
Then we created a clone repository right
from the topmost snapshot of the left
(and worked there for some weeks).
How can we merge the two graphs?
(to let the team merge between the two)
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
git tree repository branch rebase
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
We have a project repository left
.
Then we created a clone repository right
from the topmost snapshot of the left
(and worked there for some weeks).
How can we merge the two graphs?
(to let the team merge between the two)
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
git tree repository branch rebase
We have a project repository left
.
Then we created a clone repository right
from the topmost snapshot of the left
(and worked there for some weeks).
How can we merge the two graphs?
(to let the team merge between the two)
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
git tree repository branch rebase
git tree repository branch rebase
edited Nov 7 at 8:02
asked Nov 7 at 7:43
Geri
8,6911176132
8,6911176132
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
So, I think you should use git replace.
Most likely the command:
git replace --graft <commit> [<parent>…]
If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.
The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).
So the command should be:
git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>
Once done, verify the history.
If that don't suits you, delete the replaced commit.
If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all
) by rewriting all the history after the commit replaced.
From doc:
NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.
It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease
for all the refs that has been updated.
PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
1
I have updated my answer
– Philippe
Nov 7 at 11:09
1
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
1
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
1
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
|
show 10 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
So, I think you should use git replace.
Most likely the command:
git replace --graft <commit> [<parent>…]
If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.
The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).
So the command should be:
git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>
Once done, verify the history.
If that don't suits you, delete the replaced commit.
If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all
) by rewriting all the history after the commit replaced.
From doc:
NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.
It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease
for all the refs that has been updated.
PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
1
I have updated my answer
– Philippe
Nov 7 at 11:09
1
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
1
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
1
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
|
show 10 more comments
up vote
1
down vote
accepted
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
So, I think you should use git replace.
Most likely the command:
git replace --graft <commit> [<parent>…]
If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.
The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).
So the command should be:
git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>
Once done, verify the history.
If that don't suits you, delete the replaced commit.
If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all
) by rewriting all the history after the commit replaced.
From doc:
NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.
It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease
for all the refs that has been updated.
PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
1
I have updated my answer
– Philippe
Nov 7 at 11:09
1
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
1
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
1
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
|
show 10 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
So, I think you should use git replace.
Most likely the command:
git replace --graft <commit> [<parent>…]
If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.
The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).
So the command should be:
git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>
Once done, verify the history.
If that don't suits you, delete the replaced commit.
If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all
) by rewriting all the history after the commit replaced.
From doc:
NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.
It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease
for all the refs that has been updated.
PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.
NOTE: The stiching point contains the very same changeset, there are no conflicts involved.
So, I think you should use git replace.
Most likely the command:
git replace --graft <commit> [<parent>…]
If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.
The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).
So the command should be:
git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>
Once done, verify the history.
If that don't suits you, delete the replaced commit.
If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all
) by rewriting all the history after the commit replaced.
From doc:
NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.
It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease
for all the refs that has been updated.
PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.
edited Nov 7 at 11:09
answered Nov 7 at 9:17
Philippe
11.4k42543
11.4k42543
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
1
I have updated my answer
– Philippe
Nov 7 at 11:09
1
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
1
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
1
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
|
show 10 more comments
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
1
I have updated my answer
– Philippe
Nov 7 at 11:09
1
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
1
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
1
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
– Geri
Nov 7 at 9:36
1
1
I have updated my answer
– Philippe
Nov 7 at 11:09
I have updated my answer
– Philippe
Nov 7 at 11:09
1
1
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
– Philippe
Nov 7 at 12:10
1
1
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
– Philippe
Nov 9 at 21:40
1
1
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
– Philippe
Nov 10 at 9:19
|
show 10 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185269%2fhow-to-rebase-an-entire-commit-graph%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password