简体   繁体   English

查看本地和远程 Git 存储库之间的确切分歧/提交

[英]See exact divergence/commits between local and remote Git repo

Setup: 3 git repos - on github, local and on staging server.设置: 3 git 存储库 - 在 github、本地和登台服务器上。

I develop locally, push it to github and staging server pulls.我在本地开发,将其推送到 github 和登台服务器拉动。

I don't work nor commit changes on staging server, but I must have done so long time ago.我不在登台服务器上工作也不提交更改,但我一定是很久以前做过的。 Because now I get the following message when I do git status (on staging server):因为现在我在执行git status (在登台服务器上)时收到以下消息:

On branch SOME_BRANCH
Your branch and 'origin/SOME_BRANCH' have diverged,
and have 4 and 32 different commit(s) each, respectively.

My question is: how do I see those exact 4 commits that are not at origin ?我的问题是:我如何查看那些不在origin的确切4 次提交?

git rev-list origin..HEAD

这将列出分支(HEAD)中不在原点的提交。

Generically, if your remote is called foo and your branch is bar : 一般来说,如果您的遥控器被称为foo而您的分支是bar

git rev-list foo/bar..HEAD

@charlesb is the answer for being in the master branch with remote called origin. @charlesb是在具有远程被调用源的主分支中的答案。

show the commits exist in origin but not local:显示提交存在于原始但不存在于本地:

git rev-list HEAD..origin --pretty

show the commits exist in local but not origin:显示提交存在于本地但不存在于来源:

git rev-list origin..HEAD --pretty

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM