[英]How to view the committed files you have not pushed yet?
For example I commit some files, the next day some more files, and so on.例如,我提交了一些文件,第二天再提交一些文件,等等。 After some days I want to view all my committed files and view their difference with the remote repo.
几天后,我想查看我所有提交的文件并查看它们与远程存储库的区别。 Note that I have not pushed anything.
请注意,我没有推送任何内容。 I just want to verify that if I push some thing then it will go to the remote repo as I expect.
我只是想验证一下,如果我推送一些东西,那么它会按我的预期转到远程仓库。
假设您在本地分支master
,它正在跟踪origin/master
:
git diff --stat origin/master..
Here you'll find your answer:在这里你会找到你的答案:
Using Git how do I find changes between local and remote 使用 Git 如何查找本地和远程之间的更改
For the lazy:对于懒人:
- Use "git log origin..HEAD"
使用“git log origin..HEAD”
- Use "git fetch" followed by "git log HEAD..origin".
使用“git fetch”后跟“git log HEAD..origin”。 You can cherry-pick individual commits using the listed commit ids.
您可以使用列出的提交 ID 挑选单个提交。
The above assumes, of course, that "origin" is the name of your remote tracking branch (which it is if you've used clone with default options).
当然,上面假设“origin”是您的远程跟踪分支的名称(如果您使用了带有默认选项的克隆)。
The push
command has a -n
/ --dry-run
option which will compute what needs to be pushed but not actually do it. push
命令有一个-n
/ --dry-run
选项,它将计算需要推送的内容,但实际上并不执行。 Does that work for you?那对你有用吗?
I'm not great with Git, but this is what I do.我不擅长 Git,但这就是我所做的。 This does not necessarily compare with the remote repo, but you can modify the
git diff
with the appropriate commit hash from the remote.这不一定与远程存储库进行比较,但您可以使用远程的适当提交哈希修改
git diff
。
Say you made one commit that you haven't pushed...假设你做了一个你没有推送的提交......
First find the last two commits...首先找到最后两个提交...
git log -2
This shows the last commit first, and descends from there...这首先显示最后一次提交,然后从那里下降......
[jason:~/git/my_project] git log -2
commit ea7937edc8b10
Author: xyz
Date: Wed Jul 27 14:06:41 2016 -0500
Made a change in July
commit 52f9bf7956f0
Author: xyz
Date: Tue Jun 14 14:29:52 2016 -0500
Made a change in June
Now just use the two commit hashes (which I abbreviated) to run a diff:现在只需使用两个提交哈希(我缩写)来运行差异:
git diff 52f9bf7956f0 ea7937edc8b10
git diff HEAD origin/master
Where origin
is the remote repository and master
is the default branch where you will push.其中
origin
是远程存储库, master
是您将推送的默认分支。 Also, do a git fetch
before the diff
so that you are not diffing against a stale origin/master.此外,在
diff
之前执行git fetch
以便您不会与陈旧的来源/主版本发生diff
。
PS I am also new to git, so in case the above is wrong, please rectify. PS 我也是 git 新手,所以如果上面有错误,请纠正。
The previous answers are all good, but they all show origin/master.前面的回答都很好,但是都显示了origin/master。 These days, following the best practices, I rarely work directly on a master branch, let alone from origin repo.
如今,遵循最佳实践,我很少直接在 master 分支上工作,更不用说从 origin repo 了。
So if you are like me who work in a branch, here are tips:所以如果你像我一样在分行工作,这里有一些提示:
Or more simply, just use HEAD:或者更简单地说,只需使用 HEAD:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.