Git: How to check if a local repo is up to date?
Solution 1
Try git fetch --dry-run
The manual (git help fetch
) says:
--dry-run
Show what would be done, without making any changes.
Solution 2
First use git remote update
, to bring your remote refs up to date. Then you can do one of several things, such as:
git status -uno
will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same. Sample result:
On branch DEV
Your branch is behind 'origin/DEV' by 7 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
git show-branch *master
will show you the commits in all of the branches whose names end in 'master' (eg master and origin/master).
If you use -v
with git remote update (git remote -v update
) you can see which branches got updated, so you don't really need any further commands.
Solution 3
git remote show origin
Result:
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (local out of date) <-------
Solution 4
you can use git status -uno
to check if your local branch is up-to-date with the origin one.
Solution 5
Not really - but I don't see how git fetch
would hurt as it won't change any of your local branches.
Related videos on Youtube

Misha Moroshko
I build products that make humans happier. Previously Front End engineer at Facebook. Now, reimagining live experiences at https://muso.live
Updated on November 06, 2021Comments
-
Misha Moroshko over 1 year
I would like to know if my local repo is up to date (and if not, ideally, I would like to see the changes).
How could I check this without doing
git fetch
orgit pull
? -
Misha Moroshko over 11 yearsThanks! Though, it's hard to understand from the output which files were added/modified/removed.
-
Philip Oakley over 11 yearsYou get to see what tags are updated and the start..end commit range for the various branches. If this isn't sufficient, then do it as a proper fetch (not pull) which will give you a proper, separate, local copy of the remote, without affecting your own branch work. A pull would attempt to merge the two, which isn't what you want. The data transfer is the same whether you --dry-run or not.
-
Ishan Liyanage over 8 yearsIt only gives the local status, not checking with the remote branch.
-
Amanuel Nega over 8 yearsPlease confirm that! You just answered what u think! You should be more careful as newbies will tumble with it!
-
Jörg W Mittag over 8 years@AmanuelNega: This is just basic logic. If you want to know whether your local repo is in the same state as the remote repo, you need to know the state of the remote repo. Period. If you don't know the state of the remote repo, you cannot possibly know whether the local repo is in the same state. Note that the highest voted and accepted answer uses
git pull
, which the OP explicitly forbids in his question. -
Amanuel Nega over 8 yearsBe informed!
git status -uno
this works and one can also usegit show-branch *master
to see the status of all the master branches! Are you still saying it is impossible? You can see the status of any branch as long as u have access to the remote! -
Jörg W Mittag over 8 years@AmanuelNega:
git status
only tells you the status of your local refs, it does not tell you whether your local refs are up-to-date with the remote refs. Again: it is simply logically impossible to know what the state of the remote repo is without getting the state of the remote repo. Period. This is just the basic laws of spacetime. -
iconoclast about 7 yearsThis is technically correct, because the OP said "without doing
git fetch
orgit pull
". The OP didn't actually mean (as far as I can tell) "without using thegit pull
orgit fetch
commands at all" but rather "without fetching the remote repo. I think Jörg interpreted it in the first way, which is understandable. The blame could just as easily be placed on the OP—it is silly to downvote this answer. -
James Robinson over 5 yearsIt isn't "logically" impossible since self-evidently one could ring someone in your server room and say, "what is the hash of your HEAD on master branch" they could tell you and then you could check local and see that you don't have that hash. Now you know they are out of sync.
-
Paramvir Singh Karwal almost 5 yearswhy is it that when I run
git fetch --dry-run
nothing shows up? -
Philip Oakley almost 5 years@ParamvirSinghKarwal Git is sparse in what it reports. If there is nothing to say, it says nothing, as if nothing happened. Maybe you are up to date for your regular fetch's refspec. Maybe add
--all
? -
Aaron Beall over 3 yearsI don't know if git changed or I'm missing something, but
git fetch --dry-run
gives no output whengit pull
is going to pull a bunch of updates. So in other words it doesn't tell me if my branch is behind or not. -
Aaron Beall over 3 yearsWhy is this so far down?
git remote update ; git status -uno
solved it.git fetch --dry-run
gave no output even in cases where the local was behind remote. -
Aaron Beall over 3 yearsOnly gives local, but
git remote update ; git status -uno
did the trick! Thegit fetch --dry-run
gave no output when I expected it to (andgit pull
would pull things). -
DuckPuppy over 3 years@AaronBeall If that's the case, then it most likely means you have already fetched those changes locally (so nothing to fetch), but haven't yet merged them to your branch.
git pull
is roughly equivalent to agit fetch && git merge
. If you at any point ran the fetch without the--dry-run
, then you already have fetched things locally. -
Aaron Beall over 3 years@DuckPuppy Yes, so it seems
git fetch
is not sufficient to "know if my local repo is up to date". It's not clear to me if the OP didn't understand this when this answer was accepted or the question isn't clearly worded. -
Maciej Załucki over 3 years@AaronBeall Well, if OP meant checking local repository state, then that's right solution. Checking if actual working copy is up to date is different story. There are some open topics and all point that there is no such option. there is no
git merge --dry-run
norgit pull --dry-run
which is kind of pain. Always proposed solution is to fetch,git merge --no-commit --no-ff
and abort but it does not answer the question as fetch was already made. Not even mentioning not staged changes. -
Hashim Aziz almost 3 yearsThis answer is wrong and should be deleted. As it is, it perpetuates a very common but wrong myth about how Git works, one that is only dispelled when/if someone decides to read the comments to it.
-
merlit64 over 2 yearsI completely agree with this. Git pull can be damaging, overwriting files. But git fetch pulls down only the meta data, allowing commands like git status to to tell you whether your local repo is up to date or not without overwriting any files. It may not answer the letter of the question, but it answers the spirit of the question, giving you the tool you want. Git fetch, then git status will tell you where your local repo is in relation to the remote without overwriting files.
-
waykiki about 1 yearThis answer is way underrated. Running "git fetch --dry-run -v" is the simplest answer and provides more than enough info about the status of the local and remote repositories.