Change . In this GitHub repo you will find the appropriate shell scripts.
Which branch is the newest?
[...] which branch is the most modern? I mean, which branch contains the latest commits?
, ( , , ).
git for-each-ref ; - , .
Command
, ...
() .
git for-each-ref --format='%(refname:short)' \
refs/heads
, ( -):
git for-each-ref --sort='-committerdate' \
--format='%(refname:short)' \
refs/heads
, , :
git for-each-ref --count=1 \
--sort='-committerdate' \
--format='%(refname:short)' \
refs/heads
, , () ( ) : , . !
( newest-branch ) :
git config --global alias.newest-branch "for-each-ref --count=1 --sort='-committerdate' --format='%(refname:short)' refs/heads"
Git -project repo:
$ git branch
maint
* master
next
pu
$ git newest-branch
pu
$ git for-each-ref --sort='-committerdate' \
--format="%(refname:short)%09%(committerdate)"
refs/heads
pu Tue Mar 17 16:26:47 2015 -0700
next Tue Mar 17 16:14:11 2015 -0700
master Tue Mar 17 16:05:12 2015 -0700
maint Fri Mar 13 22:57:25 2015 -0700
pu - . !
?
, , newest-branch; , , - . ( , ).
Command
()
$ git symbolic-ref --short HEAD
master
, yes, , no .
if [ $(git newest-branch) = $(git symbolic-ref --short HEAD) ]; then
printf "yes\n"
else
printf "no\n"
fi
! ( isnewest):
git config --global alias.isnewest '! if [ $(git newest-branch) = $(git rev-parse --abbrev-ref HEAD) ]; then printf "yes\n"; else printf "no\n"; fi'
( , , pu .)
$ git branch
maint
* master
next
pu
$ git isnewest
no
$ git checkout pu
Switched to branch 'pu'
Your branch is up-to-date with 'origin/pu'.
$ git isnewest
yes
$ git checkout maint
Switched to branch 'maint'
Your branch is up-to-date with 'origin/maint'.
$ git is-newest-branch
no
, (•_•) ( •_•)>⌐■-■ (⌐■_■)
git ( ), , , ?
- , . DAG, git , . , :
git log --branches HEAD..
( --branches , refs/heads.) , , --oneline, --decorate ..