Git:将本地分支与远程暂存和生产进行比较

标签 git github

我在比较本地 master(与 origin/master 相同的提交)和 production/master 时遇到了问题。

$ git remote -v
origin  git@github.com:mydomain/mydomain.git (fetch)
origin  git@github.com:mydomain/mydomain.git (push)
production  git@heroku.com:mydomain-production.git (fetch)
production  git@heroku.com:mydomain-production.git (push)
staging git@heroku.com:mydomain-staging.git (fetch)
staging git@heroku.com:mydomain-staging.git (push)

我似乎能够通过 staging/master 获得差异,但我在使用 production/master 时出现错误:

$ git diff staging/master
[i'm shown diff]
$ git diff production/master
fatal: ambiguous argument 'production/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

有人看到我搞砸了吗?

我真正想做的是使用 git diff production/master...master 查看本地主机上的提交,而不是其他远程主机上的提交,但这会产生相同的错误:

$ git diff production/master...master
fatal: ambiguous argument 'production/master...master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

最佳答案

我以前用过的是

git fetch production master && git diff master production/master

您以前可能从未从那个远程获取数据。


就查看不在 production/master 上但在本地 master 上的提交而言,git log 可能更好适合:

git log --oneline production/master..master

关于Git:将本地分支与远程暂存和生产进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25559691/

相关文章:

Git 相当于 which/where

git - 如何为 gerrit 事件配置 Gerrit Webhooks

node.js - 来自私有(private) github 存储库的 npm 包,安装与更新 (package.json)

node.js - 无法将 Node.js 应用程序编译到 heroku

git - 如果不 merge ,删除后的 git 分支会发生什么?

git - 在特定起点创建分支但保留相同的远程跟踪分支

git - 为什么 git push --force 传输 blob 已经包含在远程中

github - 有没有办法在运行 gh 操作时获取工作流程 ID

github - 使用 API 在源文件内搜索 Github 存储库

git - 一切都是最新的(一切都不是)