Reputation: 1643
I want to write a fast script that checks if a remote repo has changes compared to the local one, and then pull all the changes, for all the branches, if it does.
Is there a way to do this without actually pulling all the changes, first?
Everything I've seen around git remote update
and such actually downoads stuff, etc. and it's slow for many repos.
Think of this as a sort of dry-run: run this script often for many repos and run another script to actually update the local repos based on the report of the first script.
Upvotes: 3
Views: 3511
Reputation: 1208
git fetch: is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn’t do any file transferring. It’s more like just checking to see if there are any changes available).
Once you do git fetch, you can check the status for the remote changes.
C:\D_Drive\Dev\BootApps\Persistence-Concepts>git status
On branch topic2
Your branch is behind 'origin/topic2' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Untracked files:
(use "git add <file>..." to include in what will be committed)
At this stage, your local repo do not have the changes but it shows the remote has n no of changes. So you can see the changes made at the remote without pulling.
Upvotes: 0
Reputation: 42774
If you just want to see the list of changes of a remote repository without a comparison to a local repository you can use the ls-remote
command of git:
git ls-remote https://github.com/githubtraining/hellogitworld.git
It displays the list of commit hashes of the remote repository starting with HEAD:
git ls-remote https://github.com/githubtraining/hellogitworld.git
ef7bebf8bdb1919d947afe46ab4b2fb4278039b3 HEAD
a9095e79eaafd9f11a9d12e5a1ae125fde81a5eb refs/heads/bisect
26479b0b606bc322e0b53226e44f343614bf06b6 refs/heads/fbaddfiles
c975e0e9a00f5f902877b0830a52010691586266 refs/heads/fbmaster
e650f374002f860d56ecad63b6fab7387a607642 refs/heads/feature_division
57d0bf61e57cdacb309ebd1075257c6bd7e1da81 refs/heads/feature_division_polished
7c0ffa9d88616972bb84befbec40a2212478149e refs/heads/feature_image
3c9306fcc7c41a88a37514a1f4c8d43459eaf966 refs/heads/feature_subtraction
818f033c4ae7f26b2b29e904942fa79a5ccaadd0 refs/heads/feature_subtraction_polished
....
Upvotes: 7
Reputation: 595
Technically there is no way to only looking for changes without downloading them to your local copy, however, the closest command you will find is git fetch
. Technically it downloads the changes from the remote repository but does not apply them to your working branches only updates the remote branches in your local reference.
More information here: https://git-scm.com/docs/git-fetch
Upvotes: 2
Reputation: 4210
see this SO.
TLDR
git remote update
git status -uno
or
git fetch --dry-run
Upvotes: 1