Step4: developer1 pushed commit on repo1 back to remote repo
# make sure on TestA branch
git branch
# push change back to remote
git push origin TestA
When logging back to remote repo(on github), we can see the commit pushed by developer1 just now:
Step5: developer2 tried pushing commits from repo2 back to remote repo (without pulling first)
# make sure on TestA branch
git branch
# push change back
git push origin TestA
It turned out pushing failed, git required us to pull first. The tree of repo2 has not changed till now.
Step6: developer2 git pull from repo2 TestA branch
Therefore, we git pull first to get all changes locally
git branch
git pull origin TestA
As developer1 and developer2 committed on different lines of the same file, no conflict raised. However, it is still three-way merging, with an extra merge commit.. As the screenshot above shows, when git pull, create a merge commit.
Step7: developer2 pushed commit from repo2 to the remote repo.
git push origin TestA
Now, we can see commits from github side
Step9: developer1 git pull, check git tree and git log
git pull origin TestA
git tree
git log
The git tree and git log look like: (exactly the same as repo2)
Data explored here, the merge commit will list the two parent commits as the picture above shows
Cloned the repo twice and commit in each repo to simulate two developers working on the same branch
Scenario abstraction
TestA
branch in this case);testcase2
file line2, add, commit;testcase2
file line5, add, commit;Results:
git push
, got notification togit pull
first;git pull
, auto-merging, with an extra merge commit (though no conflict, still three-way merging);TestA
branchhead
in the merge commit;git pull
now, fast-forwardData could be explored:
Detailed steps
step0: start point of the test case:
testcase2
onTestA
branch working as the start point of the testcase (SHA``)Step1: cloned two repos ( already did in testcase #1 )
To make it short, we call them:
Step2: developer1 committed in repo1, TestA branch (SHA``)
Developer1 edited
testcase2
file line10 inrepo1
TestA
branchgit add, git commit, no push yet
and git log of the file
testcase2
after commitsStep3: developer2 committed in repo2, TestA branch (SHA``)
Developer2 edited
testcase2
file line5 inrepo2
TestA
branchgit add, git commit, no push yet
Step4: developer1 pushed commit on
repo1
back to remote repoWhen logging back to remote repo(on github), we can see the commit pushed by developer1 just now:
Step5: developer2 tried pushing commits from
repo2
back to remote repo (without pulling first)It turned out pushing failed, git required us to pull first. The tree of repo2 has not changed till now.
Step6: developer2
git pull
from repo2 TestA branchTherefore, we
git pull
first to get all changes locallyAs developer1 and developer2 committed on different lines of the same file, no conflict raised. However, it is still three-way merging, with an extra merge commit.. As the screenshot above shows, when
git pull
, create a merge commit.Step7: developer2 pushed commit from
repo2
to the remote repo.Now, we can see commits from github side
Step9: developer1
git pull
, checkgit tree
andgit log
The
git tree
andgit log
look like: (exactly the same asrepo2
)Data explored here, the merge commit will list the two parent commits as the picture above shows