Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to check if a local repo is up to date?

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 or git pull ?

like image 333
Misha Moroshko Avatar asked Oct 29 '11 11:10

Misha Moroshko


People also ask

How do I know if my local repo is up-to-date?

ANSWER: you can use git status -uno to check if your local branch is up-to-date with the origin one.

How do I check for git updates?

Check Which Version of Git You're Using To check your Git version, open Command Prompt (Windows), Terminal (Mac), or the Linux terminal. The Git version you're currently using will be returned. Now that you know which version of Git you're using, you can decide if you want to update it or not.


2 Answers

Try git fetch --dry-run The manual (git help fetch) says:

--dry-run Show what would be done, without making any changes. 
like image 145
Philip Oakley Avatar answered Sep 17 '22 21:09

Philip Oakley


First use git remote update, to bring your remote refs up to date. Then you can do one of several things, such as:

  1. 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)

  1. 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.

like image 40
Piyush Agarwal Avatar answered Sep 19 '22 21:09

Piyush Agarwal