Open dorawyy opened 6 years ago
PR2 branch was derived from PR1
--> Different branches inside one repo, both Alice and Bob commit (to different files)
PR2 branch
(Pull-Request-2 branch) was derived from PR1 branch
(Pull-Request-1 branch) PR2 branch
), Bob(PR1 branch
)PR2 branch
locallygit push origin PR2
PR1 branch
locallygit push origin PR1
squash commits and merge
,
base
branch, however, no merge commit;squashed commit
is an ordinary commit, with only 1 parent;head
branch is not affected.create a merge commit
test22_option2
as test file on PR1
PR2
git checkout PR1
touch test22_option2
vim test22_option2
git add test22_option2
git commit -m "testcase22_option2: startpoint (create file test22_option2 on PR1 branch)"
git push origin PR1
git checkout PR2
git merge PR1
git push origin PR2
##### Now both PR1 and PR2 are set, at the same commit, we can start the test case
Content of test22_option2
:
Startpoint - project tree:
PR2
, pushed back to remotegit checkout PR2
vim test22_option2
# edit test22_option2, line 14
git add test22_option2
git commit -m "PR2: edited the file test22_option2, line 14"
git push origin PR2
The edit on the file test22_option2
is:
After git push origin PR2
, here is the project status:
PR1
, pushed back to remotegit checkout PR1
touch test22_option2-PR1
# edit test22_option2-PR1
git add test22_option2-PR1
git commit -m "PR1: edited the file test22_option2-PR1"
git push origin PR1
The edit on the file test22_option2-PR1
from PR1
is:
After git push origin PR1
, the two branches diverge, here is the status of PR1
:
Here is the status of the whole project:
PR1
(base) and PR2
(head)This is the page that Alice will see when she create a new pull request
:
Here are details of the pull request
, created by Alice (pull request #43 ):
squash commits and merge
squash commits and merge
Then the pull request is done
PR1
and PR2
commit historyHistory of PR1
branch:
History of PR2
branch:
Observations:
PR1
: (base
branch)
PR2
were squashed into 1, and applied to PR1
PR2
: (head
branch)
head
branchHere is the details of the squashed commit on the base branch
(PR1
in this case)
PR1
and PR2
to local again, merge, then push back to remotegit checkout PR1
git pull origin PR1
git checkout PR2
git pull origin PR2
# check tree first
The two branch still diverge ( according to the project status):
PR1
--> PR2
vs. PR2
--> PR1
)( try option3 - rebase and merge) --> to see if enabled or any conflicts?
PR1
(head) --> PR2
(base) (pull request: #44 )Details of the content is: (include two commits on PR1
)
Rebasing is enabled
PR2
(head) --> PR1
(base) (pull request: #45 )Details of the content is: (include two commits on PR1
)
Rebasing is enabled
PR1
(head) --> PR2
(base) (pull request: #44 ), choose to rebasing( suppose PR2
has new commits)
PR1
and PR2
PR1
( no change) :
PR2
(only 1 commit get applied, the squashed-commit(d94a5c3
) get passed as the textual change there is the same as 12b58d3
on PR2
):The rebase commit (on PR2
) details are ( a normal commit):
Still diverge, but pull changes to local to check project status;
# pull PR1
git checkout PR1
git pull origin PR1
After fetching all commits from PR1
, the PR1
branch status becomes:
# pull PR2
git checkout PR2
git pull origin PR2
After fetching all commits from PR2
, the PR2
branch status becomes:
The project status is:
git checkout PR1
git merge PR2
# should be a three-way merge, while no conflict
git push origin PR1
Automatic three-way merging:
Now the project status becomes:
git checkout PR2
git merge PR1
# should be a fast-forward merge
git push origin PR2
Fast-forward merging:
Now the project status becomes, all synced:
,PR2 branch was derived from PR1
--> Different branches inside one repo, both Alice and Bob commit (to different files)
PR2 branch
(Pull-Request-2 branch) was derived from PR1 branch
(Pull-Request-1 branch) PR2 branch
), Bob(PR1 branch
)PR2 branch
locallygit push origin PR2
PR1 branch
locallygit push origin PR1
rebase then merge
,
rebase then merge
test22_option3
as test file on PR1
PR2
git checkout PR1
touch test22_option3
vim test22_option3
git add test22_option3
git commit -m "testcase22_option3: startpoint (create file test22_option3 on PR1 branch)"
git push origin PR1
git checkout PR2
git merge PR1
git push origin PR2
##### Now both PR1 and PR2 are set, at the same commit, we can start the test case
Content of test22_option3
:
Startpoint - project tree:
PR2
, pushed back to remotegit checkout PR2
vim test22_option3
# edit test22_option3, line 14
git add test22_option3
git commit -m "PR2: edited the file test22_option3, line 14"
git push origin PR2
The edit on the file test22_option3
is:
After git push origin PR2
, here is the project status:
PR1
, pushed back to remotegit checkout PR1
touch test22_option3-PR1
# edit test22_option3-PR1
git add test22_option3-PR1
git commit -m "PR1: edited the file test22_option3-PR1"
git push origin PR1
The edit on the file test22_option3-PR1
from PR1
is:
After git push origin PR1
, the two branches diverge, here is the status of PR1
:
Here is the status of the whole project:
PR1
(base) and PR2
(head)This is the page that Alice will see when she create a new pull request
:
Here are details of the pull request
, created by Alice (pull request ):
rebase then merge
When rebasing is done:
PR1
and PR2
commit historyHistory of PR1
branch:
History of PR2
branch:
Observations:
PR1
: (base
branch)
head
branch (PR2
in this case)head
branch (PR2
in this case)PR2
: (head
branch)
Here is the details of the rebase commit on the base branch
(PR2
in this case)
PR1
and PR2
to local. check project statusgit checkout PR1
git pull origin PR1
git checkout PR2
git pull origin PR2
# check tree first
The two branch still diverge ( according to the project status):
PR1
--> PR2
vs. PR2
--> PR1
) again( try option3 - rebase and merge) --> to see if enabled or any conflicts?
PR1
(head) --> PR2
(base) (pull request: #50 )Details of the pull request is: (include two commits on PR1
):
Rebasing is enabled
PR2
(head) --> PR1
(base) (pull request: #52 )Details of the content is: (include one commit on PR2
)
Rebasing is enabled
PR2
(head) --> PR1
(base) (pull request: #52 ), choose to rebasing( suppose PR1
will have new commits)
The details about the merge commit is ( actually no new commit is created, this is the last rebase commit) :
PR1
(head) --> PR2
(base) (pull request: #50 ), choose to rebasing( suppose PR2
will have new commits)
PR1
and PR2
PR1
( no change) :PR2
(only 1 commit get applied, the squashed-commit(d94a5c3
) get passed as the textual change there is the same as 12b58d3
on PR2
):The rebase commit (on PR1
) details are ( a normal commit):
Still diverge, but pull changes to local to check project status;
# pull PR1
git checkout PR1
git pull origin PR1
After fetching all commits from PR1
, the PR1
branch status becomes:
# pull PR2
git checkout PR2
git pull origin PR2
After fetching all commits from PR2
, the PR2
branch status becomes:
The project status is (divergence goes further and further):
git checkout PR1
git merge PR2
# should be a three-way merge, while no conflict
git push origin PR1
Automatic three-way merging:
Now the project status becomes:
git checkout PR2
git merge PR1
# should be a fast-forward merge
git push origin PR2
Fast-forward merging:
Now the project status becomes, all synced:
PR2 branch was derived from PR1
Scenario abstract
--> Different branches inside one repo, both Alice and Bob commit (to different files)
PR2 branch
(Pull-Request-2 branch) was derived fromPR1 branch
(Pull-Request-1 branch)PR2 branch
), Bob(PR1 branch
)PR2 branch
locallygit push origin PR2
PR1 branch
locallygit push origin PR1
Results:
Option1: When
create a merge commit
,Option2: When
squash commits and merge
,Option3: When
rebase and merge
,Data could be explored:
Option1: When
create a merge commit
Option2: When
create a merge commit
Option3: When
rebase and merge
Detailed steps:
Step0: prep
PR1
branch frommaster
branchtest22
as test file onPR1
PR2
branch fromPR1
branchContent of
test22
:Startpoint - project tree:
Step1: Alice committed on
PR2
, pushed back to remoteThe edit on the file
test22
is:After
git push origin PR2
, here is the project status:Step2: Bob committed on
PR1
, pushed back to remoteThe edit on the file
test22-PR1
fromPR1
is:After
git push origin PR1
, the two branches diverge, here is the status ofPR1
:Here is the status of the whole project:
Step3: Alice made a pull request to merge
PR1
(base) andPR2
(head)This is the page that Alice will see when she
create a new pull request
:Here are details of the
pull request
, created by Alice ( pull request: #37 ):Step4: Alice work is done, now Bob's turn. He needs to decide what to do with the pull request.
Option1: Create a merge commit
Bob chose to
merge pull request
Bob filled in info when
merge pull request
Then the pull request is done
Check
PR1
andPR2
commit historyHistory of
PR1
branch:History of
PR2
branch:Observations:
PR1
:PR2
got applied back toPR1
pull request
relatedmerge commit
created onPR2
PR2
:PR2
here)Details of the
merge commit
is:Pull
PR1
andPR2
to local again, merge, then push back to remoteThe project status becomes:
Exploring question: Does commit order matters?
Answer: no, commit order not matter.
Scenario abstract
--> Different branches inside one repo, both Alice and Bob commit (to different files)
PR2 branch
(Pull-Request-2 branch) was derived fromPR1 branch
(Pull-Request-1 branch)PR2 branch
), Bob(PR1 branch
)PR1 branch
locallygit push origin PR1
base branch
commit first)PR2 branch
locallygit push origin PR2
Results:
Option1: When
create a merge commit
,Option2: When
squash commits and merge
,Option3: When
rebase and merge
,Data could be explored:
Option1: When
create a merge commit
Option2: When
create a merge commit
Option3: When
rebase and merge
Detailed steps:
Step0: prep
test22_order_test
as test file onPR1
, push to remotePR1
andPR2
Content of
test22_order_test
:Startpoint - project tree:
Step1: Bob committed on
PR1
, pushed back to remoteThe edit on the file
test22_order_test-PR1
fromPR1
is:After
git push origin PR1
, the project status is:Step2: Alice committed on
PR2
, pushed back to remoteThe edit on the file
test22
is:After
git push origin PR2
, the two branches diverge, here is the status ofPR2
:Here is the status of the whole project:
Step3: Alice made a pull request to merge
PR1
(base) andPR2
(head)This is the page that Alice will see when she
create a new pull request
:Here are details of the
pull request
, created by Alice ( pull request: # ):Step4: Alice work is done, now Bob's turn. He needs to decide what to do with the pull request.
Option1: Create a merge commit
Bob chose to
merge pull request
Bob filled in info when
merge pull request
Then the pull request is done
Check
PR1
andPR2
commit historyHistory of
PR1
branch:History of
PR2
branch:Observations:
PR1
:PR2
got applied back toPR1
( SHA the same asPR2
)pull request
relatedmerge commit
created onPR2
PR2
:PR2
here)Details of the
merge commit
is:Make a pull request the other way round
The project status becomes: