我刚刚开始学习GIT,我遇到了一个我无法弄清楚的情况。
我基本上想看看如何从远程主分支中提取更改并与我自己的主服务器合并,这样我就可以看到我是如何在实际的开发商店中从团队中获得更改的。
在master上,我创建并检出了一个名为'test'的分支。我添加了'TestTestTest.txt',添加并提交然后检出master。文件'TestTestTest.txt'不像我预期的那样。我不小心将测试分支合并到master,但删除了'TestTestTest.html然后删除并提交。无论如何我将分支'test'推送到github,创建了一个pull请求,将分支测试合并到master然后合并,所以本质上origin / master与我的本地master不同。 Origin / Master有'TestTestTest.html'文件,而我的本地主人没有。
好的,我很困惑。我跑了:
git fetch origin master
然后我跑了:
git diff master origin/master
我得到了:
diff --git a/TESTTESTTEST.txt b/TESTTESTTEST.txt
new file mode 100644
index 0000000..e69de29
好的很棒。我跑的时候:
git checkout master
git merge origin/master
我得到了:
Already up to date
这对我来说没有意义,因为我的本地主人和远程主人不同。
如果我跑:
git checkout origin/master
git log --pretty=oneline
我明白了:
e1e5344f45bb0301c9e1671b74a3803f5b29fc40 (HEAD, origin/master) Merge pull request #1 from oystagoymp/test
66338a8823d2a8bba3f1f076a45265e4dfca42d6 (origin/test, test) Added a test message to see if it works when I pull from master
1a223cbf5243ae004e2d2b6156470274bb626f7e (backup) added tabs functionality
8943feab9a240339b70b4d19abfdea40a51810f7 Created template and tabs page
263a4bd65e1dacac84748ec941217839dc4435e0 Event emitting
2f4c6247a2229edf22ce09b72a6a06f8de8491df toggle functionality implemented
4ddd0442b36631460ec720d4b96ca2fb6fd558a8 working message component - basic
ad6c716d9558b7cefbae6422b78a916f3e19e37f Added empty message html page
2d2997c5d0128254b7385cb1bb80282bfc679b4a First component including javascript and edited source file
92b5a02b51512d0269de2ad604057f079f99e999 Working tasks program with add
785516c8d4afa5ab53d51d427dad20f392eca403 commiting tasks after filter and incomplete add
337baa1d13a434c1fe18d78bf436da7e0ec8e602 Initial commit of first vue code file
如果我跑:
git checkout master
git log --pretty=oneline
我明白了:
26b19af199eaa20a280e22513c97e469a7d8b5da (HEAD -> master) Merge remote-tracking branch 'origin/master'
e1e5344f45bb0301c9e1671b74a3803f5b29fc40 (origin/master) Merge pull request #1 from oystagoymp/test
460c60e90e6762e89544920a2ced3698840b0f74 removed TestTestTEst.txt
66338a8823d2a8bba3f1f076a45265e4dfca42d6 (origin/test, test) Added a test message to see if it works when I pull from master
1a223cbf5243ae004e2d2b6156470274bb626f7e (backup) added tabs functionality
8943feab9a240339b70b4d19abfdea40a51810f7 Created template and tabs page
263a4bd65e1dacac84748ec941217839dc4435e0 Event emitting
2f4c6247a2229edf22ce09b72a6a06f8de8491df toggle functionality implemented
4ddd0442b36631460ec720d4b96ca2fb6fd558a8 working message component - basic
ad6c716d9558b7cefbae6422b78a916f3e19e37f Added empty message html page
2d2997c5d0128254b7385cb1bb80282bfc679b4a First component including javascript and edited source file
92b5a02b51512d0269de2ad604057f079f99e999 Working tasks program with add
785516c8d4afa5ab53d51d427dad20f392eca403 commiting tasks after filter and incomplete add
337baa1d13a434c1fe18d78bf436da7e0ec8e602 Initial commit of first vue code file
有谁知道为什么GIT认为我的本地大师是最新的?我觉得GIT不可或缺,我不理解。
谢谢!
答案 0 :(得分:1)
您的master
(26b19af1)分支已位于origin/master
(e1e5344f)之上,因此它为Already up to date
。这只是意味着master
已经拥有origin/master
中存在的所有提交。
由于master
和origin/master
未引用相同的哈希修订版,git diff
将显示差异。