Find out which local branches are not in sync with the remote

Suppose I have a git repository with multiple branches. I suspect that some of the branches were not pushed upstream or out of date, or both (i.e. diverged).

Is there any way to find out which branches are not synchronized with the console with one command? (The script entry is fine, but I would like to know if there is already such a script).

+6
source share
4 answers

I made a script. Turns off git branch -v gives the necessary information.

~ / bin / git -total.sh:

 #!/bin/sh for DIR in " $@ "; do # Only git dirs interesting [ -d "$DIR/.git" ] && cd "$DIR" || continue # git branch -v gives ahead/behind info # using perl - sorry for this MOD=`git branch -v | perl -wlne '/^..(\S+)\s+([a-f0-9]+)\s+(\[ahead\s+(\d+)\])/ or next; print "# Branch ahead: $1"; '`; # a series of UGLY HACKs to get pretty-printing [ ! -z "$MOD" ] && MOD=" $MOD" git status | grep -q '^# Changes' && MOD="$MOD # Uncommitted changes present" # print summary [ ! -z "$MOD" ] && echo -e "$DIR:$MOD" cd - done 
+5
source

This may help you: git remote show origin I'm not sure, but it works for me

+4
source

This uncommitted project uncommitted does what you want.

+1
source

Well, to find out if the remote has changed or not, you need at least one git fetch to update deleted links. After that, the git status will tell you that you are behind or ahead of the distance, and how many commits.

0
source

Source: https://habr.com/ru/post/913530/


All Articles