tags:

views:

192

answers:

4

Is there a way to see what would be pushed if you did a git push command?

What I'm picturing is something like the "Files Changed" tab of Github's "pull request" feature. When you issue a pull request, you can look and see what will be pulled in if they accept your pull request: github example of aggregate changes

Command line is OK, but I'd prefer some sort of GUI (like the screenshot above).

+6  A: 

There is always dry-run:

git push --dry-run

It will do everything except for the actually sending of the data.

If you want a more graphical view you have a bunch of options.

Tig and the gitk script that come with git both display the current branch of your local copy and the branch of the remote or origin.

alt text

So any commits you make that are after the origin are the commits that will be pushed.

Open gitk from shell while in the branch you want to push by typing gitk&, then to see the difference between what is on the remote and what you are about to push to the remote, select your local unpushed commit and right-click on the remote and choose "Diff this -> selected": alt text

Brian Gianforcaro
git push --dry-run doesn't show me anything like what I'm hoping to see.gitk is closer, but it doesn't show me the aggregate total of all changes that will be pushed. So if I'm pushing 6 commits to remote, I want to see the sum total of what will be pushed. I don't care what each commit has individually because one commit could be completely negated by the next.
cmcculloh
+1 for those nice graphics
kenny.r
+1  A: 

Use git gui, there you can see a list of what changed in your actual commit. You can also use gitk wich provides an easy interface for reflogs. Just compare between remotes/... and master to see, what will be pushed. It provides an interface similar to your screenshot.

Both programs are included in git.

FUZxxl
I don't see any place in git gui that shows everything that has been committed but not pushed.
cmcculloh
In git gui you can see, what's modified but not commited. In gik (Via `gitk --all` you get a complete list of all comments. Now you can compare the actual state of your dev-branch with your remote to push.
FUZxxl
+9  A: 

For a list of files to be pushed, run:

git diff --stat [remote/branch]

example:

git diff --stat origin/master

For the code diff of the files to be pushed, run:

git diff

To see full file paths of the files that will change, run:

git diff --numstat [remote repo/branch]

If you want to see these diffs in a GUI, you will need to configure git for that. See http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program.

Ionuț G. Stan
Both variations of git diff --cached without a commitish given will only display the differences w/regards to HEAD. I think you meant git diff [--stat] --cached origin/master, assuming the origin's main branch is master
mfontani
@mfontani, yes you're right. Now I realize that what I actually answered to, was a way to see what will be committed, not pushed. So, yes, a path should be given.
Ionuț G. Stan
This isn't exactly what you want. You should diff `HEAD`, not the index, against origin (`git diff origin/master HEAD`). Diffing the index will give the same results if and only if you have no changes staged for commit. If you have changes staged, they'll be included in the diff, but clearly won't be pushed since they haven't been committed yet.
Jefromi
A: 

You probably want to run git difftool origin/master.... that should show the unified diff of what is on your current branch that is not on the origin/master branch yet and display it in the graphical diff tool of your choice. To be most up-to-date, run git fetch first.

Scott Chacon