threads / rfc / 42919

[RFC] git subcommand to check if branch is up-to-date with upstream

Subject: [RFC] git subcommand to check if branch is up-to-date with upstream

## tl;dr

4 messages between Jul 25, 2016 and Jul 26, 2016.

replies: 3people: 3as markdown or json

Sidhant Sharma· Jul 25, 2016, 12:58 UTC · lore

Hi, I was wondering if it would be a good idea to have a command to check if a push or pull is required. Perhaps it can also suggest if changes are fast-forward or the branches (local and remote) have diverged. The reason I feel the need of such a command is when I need to check if my branch is up-to-date with the remote, and when I need to know if my local has diverged. Currently I use a script based on this stackoverflow answer[1] Not an extremely useful tool, but I thought it'll be good to have it.

Warm regards, Sidhant Sharma

[1] http://stackoverflow.com/a/3278427/5211579
Junio C Hamano· Jul 25, 2016, 16:58 UTC · re: Sidhant Sharma · lore

Re: [RFC] git subcommand to check if branch is up-to-date with upstream

Sidhant Sharma <tigerkid001@gmail.com> writes:
> I was wondering if it would be a good idea to have a command to check if a
> push or pull is required. Perhaps it can also suggest if changes are
> fast-forward or the branches (local and remote) have diverged.

Doesn't "branch -v" give that information these days? You'd need to "fetch" first to get the up-to-date worldview before running it, of course.

Jakub Narębski· Jul 25, 2016, 17:33 UTC · re: Junio C Hamano · lore

Re: [RFC] git subcommand to check if branch is up-to-date with upstream

W dniu 2016-07-25 o 18:58, Junio C Hamano pisze:
Show 9 quoted lines
> Sidhant Sharma <tigerkid001@gmail.com> writes:
> 
>> I was wondering if it would be a good idea to have a command to check if a
>> push or pull is required. Perhaps it can also suggest if changes are
>> fast-forward or the branches (local and remote) have diverged.
> 
> Doesn't "branch -v" give that information these days?  You'd need to
> "fetch" first to get the up-to-date worldview before running it, of
> course.

You need "branch -v -v". For current branch, you can simply run "git checkout". All this is the information for end user, not scripts.

$ git branch -v -v
* gitweb-docs   4ebf58d [origin/master: ahead 1] gitweb(1): Document query parameters
  master        08bb350 [origin/master] Sixth batch of topics for 2.10
$ git checkout
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
-- 
Jakub Narębski
Sidhant Sharma· Jul 26, 2016, 09:32 UTC · re: Jakub Narębski · lore

Re: [RFC] git subcommand to check if branch is up-to-date with upstream

On Monday 25 July 2016 11:03 PM, Jakub Narębski wrote:
Show 20 quoted lines
> W dniu 2016-07-25 o 18:58, Junio C Hamano pisze:
>> Sidhant Sharma <tigerkid001@gmail.com> writes:
>>
>>> I was wondering if it would be a good idea to have a command to check if a
>>> push or pull is required. Perhaps it can also suggest if changes are
>>> fast-forward or the branches (local and remote) have diverged.
>> Doesn't "branch -v" give that information these days?  You'd need to
>> "fetch" first to get the up-to-date worldview before running it, of
>> course.
> You need "branch -v -v". For current branch, you can simply run "git checkout".
> All this is the information for end user, not scripts.
>
> $ git branch -v -v
> * gitweb-docs   4ebf58d [origin/master: ahead 1] gitweb(1): Document query parameters
>   master        08bb350 [origin/master] Sixth batch of topics for 2.10
>
> $ git checkout
> Your branch is ahead of 'origin/master' by 1 commit.
>   (use "git push" to publish your local commits)
>
Nice, didn't know that one. Thanks for the tip.

Regards, Sidhant Sharma

← back to recent threads