2

I checked out a branch, made changes, added changes and committed. I did not push the changes.

When I do a git status it tells me

Switched to branch 'develop'
Your branch is ahead of 'origin/develop' by 2 commits.
  (use "git push" to publish your local commits)

Is there a way one can know what changes (files/code) are waiting to be pushed ?

Andrew Hendrie
  • 6,205
  • 4
  • 40
  • 71
happybuddha
  • 1,271
  • 2
  • 20
  • 40
  • If the output you gave above is really the extent of `git status`, then it would appear that you have no changed files. Did you recently commit your work? – Tim Biegeleisen Jan 22 '16 at 04:58
  • http://stackoverflow.com/questions/11935633/git-diff-between-remote-and-local-repo - git diff doesn't just work on your local repo, you can get the difference between a huge selection of things. Git status (by default) only works locally so, if you've committed all changes locally it will see no differences. The HieroB answer at that link seems better than the currently accepted one since it gives detailed commands. – paxdiablo Jan 22 '16 at 05:01
  • @OP: You can note the count of "2 commits" and run `git log --stat`. Look at the first two commits, and note the files that were changed. These are the 2 commits that are waiting to be pushed. – Nayuki Jan 22 '16 at 05:09
  • To check the code changes that you will make if you push to master - do `git stash` to clear up the uncommitted changes (these wont be pushed) then do `git diff origin/master` to check the changes you will make to master (if you push the commits) and then do `git stash pop` to restore your local file changes back to as it were before. – Harish Ved Jan 22 '16 at 05:09
  • I tried all that was suggested. log doesn't show the files, just the commit messages. @paxdiablo I tried doing with HieroB suggested, but the diff still doesn't show the changes. I remember changing at least a few files, which for the life of me I can't remember – happybuddha Jan 22 '16 at 05:42
  • @TimBiegeleisen No, it was a while ago. – happybuddha Jan 22 '16 at 05:43
  • I don't think I have ever seen `git status` show no files changed when there in fact were file changes. So try to push, and if it doesn't work, then come back here with the error output. – Tim Biegeleisen Jan 22 '16 at 05:44

3 Answers3

2

git diff origin/develop will show the difference from your current branch to origin/develop.

git diff origin/develop develop will show the difference between origin/develop and develop branches when you are on any branch.

1615903
  • 32,635
  • 12
  • 70
  • 99
1

I personally prefer using this command to find out what's going on in my git repository:

git log --graph --all --decorate

Try it, and you will see where is your develop branch and where is origin/develop and what commits are not yet pushed to origin/develop.

Also you might find this alias helpful.

Anton Serdyuk
  • 1,208
  • 10
  • 13
1

You can try:

git log --name-status origin/develop..develop

Show the commits that are in the "develop" branch but not yet in the "origin/develop" branch, along with the list of paths each commit modifies.

Cosmin Ordean
  • 165
  • 1
  • 9