简体   繁体   English

如何确认当前git diff是当前和最后一个,而不是当前提交和其他任何一个

[英]how to confirm that current git diff is one with current and last and not with current commit and any other

I am making a tool in python to push and obviously I would want to push the last commit so if I am checking the diff of the last I want to push but if the diff is not of current and last HEAD, then git push should not work. 我在python中制作了一个工具来推送,显然我想推送最后一个提交,因此,如果我正在检查要推送的最后一个提交的差异,但是如果差异不是当前和最后一个HEAD的差异,则git push不应工作。

How to check if the git diff is between current head and last head ie git diff HEAD^ HEAD and not any other ? 如何检查git diff是否在当前头部和最后一个头部之间,即git diff HEAD^ HEAD而不是其他任何git diff HEAD^ HEAD

why I need functionality? 为什么我需要功能?

because Diff I am seeing is the diff I am going to send in email. 因为我看到的Diff是我要发送的电子邮件中的Diff。 however would that make sense I see a different diff and push the last commit . 但是,我会看到不同的差异并推动最后的提交有意义吗?

which is why I am trying to figure out if diff being displayed is of current and last commit only then i should push else not. 这就是为什么我试图弄清楚是否显示的diff仅是当前的和最后一次提交,然后我应该推送else而不是。

I sense a simple git status or git diff --cached would be enough to make sure that the last commit is indeed the last one, meaning there is no work in progress, some of it already added to the index, which could constitute a new commit. 我感觉到简单的git statusgit diff --cached足以确保最后一次提交确实是最后一次提交,这意味着没有正在进行的工作,其中一些已经添加到索引中,这可能构成一个新的承诺。

If git status doesn't mention any file added to the index, then you can push your last commit. 如果git status没有提到任何添加到索引的文件,则可以推送上一次提交。

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

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