Git有哪些命令来完成下面的工作流程?

场景

我从一个存储库克隆,并将自己的一些文件提交到本地存储库。与此同时,我的同事对远程存储库进行了提交。现在,我想:

检查是否有新的 提交给其他人 远程存储库,即原点? 上有三个新的提交 远程存储库 拉,我想区别 远程存储库的提交,即。 头~3与头~2,头~2与 HEAD~1和HEAD~1与HEAD。 在知道远程发生了什么变化后, 我想获取最新的提交 从其他人那里。

我目前的发现

对于第二步:我知道插入符号HEAD^, HEAD^^等,以及波浪符号HEAD~2, HEAD~3等。

对于第三步:那就是,我猜,只是一个git拉。


当前回答

您可以git获取origin来更新存储库中的远程分支以指向最新版本。与遥控器不同的是:

git diff origin/master

是的,你也可以使用插入符号。

如果你想接受远程更改:

git merge origin/master

其他回答

您可以git获取origin来更新存储库中的远程分支以指向最新版本。与遥控器不同的是:

git diff origin/master

是的,你也可以使用插入符号。

如果你想接受远程更改:

git merge origin/master

综合看待“起源”的一个好方法是:

git remote show origin

一个潜在的解决方案

感谢Alan Haggai Alavi的解决方案,我提出了以下潜在的工作流程:

步骤1:

git fetch origin

步骤2:

git checkout -b localTempOfOriginMaster origin/master
git difftool HEAD~3 HEAD~2
git difftool HEAD~2 HEAD~1
git difftool HEAD~1 HEAD~0

步骤3:

git checkout master
git branch -D localTempOfOriginMaster
git merge origin/master
git remote update && git status 

在检查Git中是否需要拉的答案上发现了这个

git remote update to bring your remote refs up to date. Then you can do one of several things, such as: git status -uno will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. git show-branch *master will show you the commits in all of the branches whose names end in master (eg master and origin/master). If you use -v with git remote update you can see which branches got updated, so you don't really need any further commands.

我经常问的问题是“回购中有什么新的或改变的吗”,所以改变的东西就会派上用场。在这里找到的。

git whatchanged origin/master -n 1