简体   繁体   中英

How to tell which local branch is out of date with remote branch

I'm usually tracking many remote branches. After I do a

git fetch

to get all the latest updates from all tracking branches. Is there a single command to see which remote branch I just fetched is ahead of my local branch?

Currently, I'm manually switching to each local branch to get the message

Your branch is behind 'origin/xyz' by 1 commit, and can be fast-forwarded.

Would be nice if there is a single command that will tell me which local branch is behind of the tracking remote branch.

EDIT: I suppose this could do this:

git remote show origin

But it requires a network connection, which should not really be needed since I already did a git fetch . The information should be available locally, even if possibly stale.

Answering my own question

git branch -v

would do. Use double v to see the remote branch name too

git branch -vv

Example output from git branch -vv on an out-of-date local branch:

* master 3795de5 [origin/master: behind 1] Remove bad library search paths.

Note the "behind 1". There is another commit on the remote branch (can't tell what it is from this output) which comes after the local 3795de5 commit of "Remove bad library search paths."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM