简体   繁体   English

查找已提交但未推送的 git 文件

[英]find git files that are committed but not pushed

The normal git workflow is正常的 git 工作流程是

  • Edit files编辑文件
  • git add添加
  • git commit提交
  • git push

I am trying to find a command that tells me if there is anything that has been committed but not pushed.我试图找到一个命令来告诉我是否有任何已提交但未推送的内容。 I have tried我试过了

git diff --stat --cached master

But this gives the same result before and after a push, but I thought that a push would removed the changed files from that staging area但这在推送前后给出了相同的结果,但我认为推送会从该暂存区中删除更改的文件

Please can someone tell me the correct command for this.请有人告诉我正确的命令。

When you've committed but not yet pushed, your local branch is ahead of (or has diverged from) it's upstream branch (usually origin/BRANCHNAME ).当您提交但尚未推送时,您的本地分支领先于(或偏离)它的上游分支(通常是origin/BRANCHNAME )。

In general, you can see this with一般来说,你可以看到这个

git status

which will say something like这会说类似的话

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

If you want to see specifically what files changed, something like如果您想具体查看哪些文件发生了变化,例如

git diff --stat origin/master..HEAD

will show you (the generalized version, if you want a script to cope with any branch and remote, is harder).会告诉你(通用版本,如果你想要一个脚本来处理任何分支和远程,更难)。

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

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