Git Workflow, Nvie Branching Model Ahead and Behind

本小妞迷上赌 提交于 2019-12-06 17:06:49
git log origin/master ^origin/develop

This command displays all commits reachable from origin/master but not from origin/develop

git log origin/develop ^origin/master

This command displays all commits reachable from origin/develop but not from origin/master

The output from both these above commands seem to be consistent with the graph you've shown.

If you intend to find out the difference in the contents of the 2 branches, you should be using the git diff command instead.

git diff origin/master..origin/develop

If you want only the list of files which are different, you can use the --name-status option:

git diff --name-status origin/master..origin/develop

In git, a commit's SHA1 is calculated based on the parent commit's SHA1, the commit message, the timestamps, and lot of other such information. Although you've merged the same release-v3.0.1 branch into both master and develop, you've done it as 2 independent merges at 2 different time instants. This would obviously not produce the same commit SHA1 for both.

What you should've done instead is one of the following:

Option 1:

git checkout master:
git merge release-v3.0.1

git checkout develop:
git merge master

git checkout master
# This would be a fast-forward merge
git merge develop

Option 2:

git checkout develop:
git merge release-v3.0.1

git checkout master:
git merge develop

git checkout develop
# This would be a fast-forward merge)
git merge master

This way you would end up with both master and develop branches pointing to the same commit.

You could get to the same state even now by merging either master into develop or the other way around, and doing a fast-forward merge on the other branch.

git checkout master
git merge develop

git checkout develop
# This would be a fast-forward merge
git merge master
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!