Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check the status of a remote Git repository?

Tags:

git

I have a remote Git repository to which I can push/pull from a local repository via SSH.

I can use the Git status command to check the untracked/unstaged files in the local repository. How do I do the same with the remote repository?

Please note that I'm not looking at finding the differences between the local commit and the remote commit.

like image 625
John Avatar asked Sep 20 '13 17:09

John


1 Answers

git fetch --dry-run --verbose may show what you need.

Example:

# Before a remote update:
user@localhost:~/build/demo/myrepo$ git fetch --dry-run --verbose
From https://gitserver.local/git/myrepo
 = [up to date]      master     -> origin/master

# After a remote update:
user@localhost:~/build/demo/myrepo$ git fetch --dry-run --verbose
POST git-upload-pack (328 bytes)
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
From https://gitserver.local/git/myrepo
   83619a7..67ea28b  master     -> origin/master

Caveats:

  • The exit code does not reflect your local repository being in sync with the remote repository; it only reflects on the action itself being successful or not.
  • If your local repository contains newer changes than the remote repository, Git fetch still considers your local repository up to date. Maybe git push --dry-run helps for this case.
like image 69
Boi Sletterink Avatar answered Oct 01 '22 19:10

Boi Sletterink