How can we view or get a diff file for an unpushed commit by another person (not by me) with the sha/commit ID. I see many answers for the commits made by myself Viewing Unpushed Git Commits, but didn't see for someone else's commit.
2 Answers
This is not possible by definition. A commit that someone else hasn't pushed is local to their machine.
The only way to see unpushed commits would be to log into whatever machine they are working on, and cd
into their working directory if they're willing to let you do that. Then, run the same commands you would in your own local git clone. However, this is equivalent to acting as them, from git's point of view.

- 71,677
- 44
- 195
- 329
-
There are some review tools (e.g. gerrit) which shows the diff to the reviewers. This is initiated once the author sends a review request. So mostly then in that case I believe the tool may be accessing it with the owners right. – Ginu Jacob Mar 13 '18 at 03:14
-
@GinuJacob, Sorry I think I misunderstood the question. If someone has sent a review out for an unpushed commit, this is morally equivalent to pushing it out to a branch or just emailing you a patch with the diff. In the former case, you should be able to pull the branch and diff with master (if you can determine what the branch is). In the latter, you can just apply the patch and locally git diff. – merlin2011 Mar 13 '18 at 03:47
-
This is not morally equivalent to pushing, this is exactly pushing. To send a review request to gerrit one has to push, period. – phd Mar 13 '18 at 10:04
-
@phd, I'm trying to keep my comment general; I'm not sure I'm comfortable claiming that *all* review systems are based on an actual git push, even if gerrit is. :) – merlin2011 Mar 13 '18 at 18:45
To see what's in someone else's repo, you need to add their repo as a remote with git remote add
. That requires that the repo be accessable to you via a URL, which requires some work on the part of the owner. If they grant you ssh access to their machine, you can use a ssh:
url to access their repo. If they're running a web service, they can set it up so that you can access it via http:
or https:
. Alternately, they can run git daemon
to run a little read-only git:
service.

- 119,907
- 13
- 134
- 226
-
*requires that the repo be accessable to you* Another variant — both developer and reviewer could use an intermediate repository accessible to both. – phd Mar 13 '18 at 20:13