Vova
Vova

Reputation: 670

Check if master branch have new commits

Is where are a better way to understand is where any new commit will be fetched with git fetch when:

git fetch origin --dry-run -v 2>&1| grep 'master'| grep 'up to date'

And then, if output looks like:

= [up to date]      master     -> origin/master

I will not need to do actual fetch, and if not - i do a fetch.

I'm using this method right now, but i wonder is where are a better solution?

Also i want to check similar thing for hg - is where are a way to do so?

Upvotes: 0

Views: 1336

Answers (1)

Marina Liu
Marina Liu

Reputation: 38116

You can use git fetch --dry-run to check if remote has new changes to fetch. It will

show what would be done without making any changes

.

Also you can use hg incoming to check if there has changes to fetch.

Mercurial provides the hg incoming command to tell us what changes the hg pull command would pull into the repository, without actually pulling the changes in.

Upvotes: 3

Related Questions