git – commands -list “unpushed” files

Background

Let us identify the differences between our local git repository and its GitHub version.

Commands

 

Popular Commands

If one Google’s on “show unpushed files“, the more popular hits will be samples that resemble the one’s listed below:-

  1. git diff origin/master..HEAD

 

Command – git diff origin/master..HEAD

Command


git diff origin/master..HEAD

 

Output

Text

>git diff origin/master..HEAD
fatal: ambiguous argument 'origin/master..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Image

 

Explanation

The error message “fatal: ambiguous argument ‘origin/master..HEAD’: unknown revision or path not in the working tree.“, is not terribly illuminating.

Troubleshooting

Error messages can be defeating at times, but let us give it the old try a bit harder approach.

As we talking about source control, “origin/master..HEAD”, sounds and seems indicative of branch ids.

Branches

Let us try to determine our current local and remote branches.

Outline

  1. List all git branches
    • git branch -a
    • git branch -all
  2. List local git branches
    • git branch
    • git branch -l
    • git branch –list
  3. List remote git branches
    • git branch -r
    • git branch –remotes

 

Syntax


git branch [option]

 

Sample


>git branch -a
* main
  remotes/origin/main


 

Output

Output – Image

Output – Text


>git branch -a
* main
  remotes/origin/main

Explanation

It appears that:-

  1. Our local branch is called main
  2. And, that our lone remote branch is “remote/original/main

In essence, we do not have branches, just our mainline.

 

Commands

Git diff

Outline

  1. Compare Committed Changes with Remote
    • name only
      • Syntax
        • git diff –name-only remotes/local
      • Sample
        • git diff –name-only remotes/origin/main..main
  2. Compare Both Committed & Uncommitted  Changes with Remote
    • name only
      • Syntax
        • git diff –name-only remotes
      • Sample
        • git diff –name-only remotes/origin/main
    • name and status
      • Syntax
        • git diff –name-status remotes
      • Sample
        • git diff –name-status remotes/origin/main
  3. git diff origin/main

 

Git Diff – Locally Committed Changes against Remote – List filenames only

Syntax


git diff --name-only &lt;remote-branch&gt;..&lt;local-branch&gt;

Sample


git diff --name-only remotes/origin/main..main

Output

Text

&gt;git diff --name-only remotes/origin/main..main
gitAdd.cmd
gitStatus.cmd

Image

Explanation

  1. The files identified are:-
    • gitAdd.cmd
    • gitStatus.cmd

 

Git Diff – Locally Committed Changes & Uncommitted Changes against Remote – List filenames only

Syntax


git diff --name-only &lt;remote-branch&gt;

Sample


git diff --name-only remotes/origin/main

Output

Text

&gt;git diff --name-only remotes/origin/main
gitAdd.cmd
gitStatus.cmd
helloWorld.rs
Image

Explanation

  1. The files identified are:-
    • gitAdd.cmd
    • gitStatus.cmd
    • helloWorld.rs

 

Git Diff – Locally Committed Changes & Uncommitted Changes against Remote – List filenames and file Status

Syntax


git diff --name-status &amp;lt;remote-branch&amp;gt;

Sample


git diff --name-status remotes/origin/main

Output

Text

>git diff --name-status remotes/origin/main
M gitAdd.cmd
M gitStatus.cmd
A helloWorld.rs
Image

Explanation

  1. The files identified are:-
    • gitAdd.cmd ( Modified )
    • gitStatus.cmd ( Modified )
    • helloWorld.rs ( Added )

 

 

Summary

Social Progress, such as trying not to use master and slave indicators impact all worlds.

Real World and Virtual.

I will say stay socially connected and aware and it might help you when troubleshooting software; especially when you run into seeming obtuse errors.

 

Dedicated

Dedicated to all those brave men and women who work for the public good.

Santa Clara Valley Transit Authority (VTA), still you rise.

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s