I want to get a list 에 있는 모든 분기로서의 Git 리포지토리를 " freshest"; 맨 위에 있는 분기로서의 " freshest"; # 39 의 커밋되었습니다 한 that& () 은 가장 최근에 () 이며, 따라서 내가 원하는 하나일 가능성이 더 많은 주의를 기울여야 할).
내가 할 수 있는 방법이 깃 (git) (a) 을 사용하여 목록에 의해 분기로서의 정렬하려면 최신값 로칼에서 또는 (b) 와 함께 # 39 의 목록을 가져올 분기로서의 각 one& 마지막 커밋합니다 함정이거나 기계가 읽을 날짜 형식?
항상 최악의 같아 실행하십시오 깃 (git) ',' 모든 분기로서의 분기로의 afaq 바뀌엇어요 구문 분석, 그 후 '1' - 형식 = format:%ci 프란치나미 뻨을 로깅합니다 출력입니다 깃 (git) 을 얻기 위해 각 각 선택기에 branch& # 39 의 커밋합니다 바뀌었다. 하지만 이 Windows 를 실행할 수 있는 새로운 프로세스를 시작하기 때문에 상대적으로 비싼 https://xxx. 회전하는 백업하도록 실행가능파일 한 번씩 분기로의 느린 경우에는 많은 분기로서의 깃 (git) 을 받을 수도 있다. 이 모든 작업을 수행할 수 있는 방법이 하나의 명령어로?
또한 이후 2.7.0 깃 (git) 의 'git 분기로의':
git for-each-ref --sort=-committerdate refs/heads/
# Or using git branch (since version 2.7.0)
git branch --sort=-committerdate # DESC
git branch --sort=committerdate # ASC
[결과] (http://i.imgur.com/AlaP8dD.png)!
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
[결과] (http://i.imgur.com/tDCTiZx.png)!
git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)'
[1]: # 5188364 https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit/5188364 [2]: https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit # comment5837438_5188364
다음은 간단한 명령을 통해 모두 나열하는 분기로서의 최신값 커밋한:
git branch -v
Order by 사용할 수 있는 최신 로칼에서
git branch -v --sort=committerdate
출처: http://git-scm.com/book/en/Git-Branching-Branch-Management
난 다음 별칭:
최근 ᄅ씨 () {- = - =;! '" 깃 (git) = & # 39 각 참조 정렬하려면 코미터다테 참조 / 앞면이야 - 형식 (헤드), % % (색상 노란색) % (세나미: 파선-짧은) % (색상: 굵은체의 녹색) % (코미터다테: 상대) % (파란색을) % (주제) % (색상 마젠타색) % # 39, & # 39 (오손임) % (색상 재설정하지), & # 39 ts& 열 -;;} r". '
생산하는:
! 결과
& # 39, & # 39 사용합니다. 구분할 수 있습니다.
[2]: https://stackoverflow.com/users/189247/bj%C 3 %B6rn-lindqvist
난 또 필요 없이 참조입니다 별색을 주기표시 및 원격 복제:
for ref in $(git for-each-ref --sort=-committerdate --format="%(refname)" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:"%Cgreen%cr%Creset %C(yellow)%d%Creset %C(bold blue)<%an>%Creset%n" | cat ; done | awk '! a[$0]++'
다음은 어려울 수 있기 때문에, 말을 인용해 앨리어스입니다 내주었다.
alias glist='for ref in $(git for-each-ref --sort=-committerdate --format="%(refname)" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:"%Cgreen%cr%Creset %C(yellow)%d%Creset %C(bold blue)<%an>%Creset%n" | cat ; done | awk '"'! a["'$0'"]++'"
내가 나 자신에게 가장 적합한 이전 사례를 참조할 무언가를 만들어낼 수 있었습니다.
>. 깃 (git) = - 코미터다테 refs/heads/ 정렬하려면 각 참조 - >. - 형식 = & # 39, % (오토르다테: 파선-짧은) % (붉은 색:) % % (색상 노란색) % (개체 이름: 파선-짧은) (세나미 파선-짧은) % (색상 재설정하지) >. (% (색상 녹색) % (코미터다테: 상대) % (재설정하지 색상:)) & # 39.
그래서 한 줄 광고문 - vv 깃 (git) ',' s # 39 here& 신규인지 분기로의 그대로 유지할 수 있는 컬러 등을 통해 커밋합니다 날짜:
<! - 언어: > 내주었다.
git branch -vv --color=always | while read; do echo -e $(git log -1 --format=%ct $(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g') 2> /dev/null || git log -1 --format=%ct)"\t$REPLY"; done | sort -r | cut -f 2
이 경우, 이 버전은 또한 인쇄하려면 커밋합니다 날짜 대신 사용할 수 있습니다.
<! - 언어: > 내주었다.
git branch -vv --color=always | while read; do echo -e $(git log -1 --format=%ci $(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g') 2> /dev/null || git log -1 --format=%ci)" $REPLY"; done | sort -r | cut -d ' ' -f -1,4-
견본입니다:
2013-09-15 master da39a3e [origin/master: behind 7] Some patch
2013-09-11 * (detached from 3eba4b8) 3eba4b8 Some other patch
2013-09-09 my-feature e5e6b4b [master: ahead 2, behind 25] WIP
아마 더 판독값 분할됩니다 it& # 39 의 여러 선:
<! - 언어: > 내주었다.
git branch -vv --color=always | while read; do
# The underscore is because the active branch is preceded by a '*', and
# for awk I need the columns to line up. The perl call is to strip out
# ansi colors; if you don't pass --color=always above you can skip this
local branch=$(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g')
# git log fails when you pass a detached head as a branch name.
# Hide the error and get the date of the current head.
local branch_modified=$(git log -1 --format=%ci "$branch" 2> /dev/null || git log -1 --format=%ci)
echo -e "$branch_modified $REPLY"
# cut strips the time and timezone columns, leaving only the date
done | sort -r | cut -d ' ' -f -1,4-
이렇게 하면 또 다른 인수 목록 '을' vvr 의 작동합니까 git 원격입니다 추적 branch ',' 예 '또는' 바바 원격입니다 추적 branch) 와 지역 모두 나열할 수 있다.
git 2.7 (Q4 2015년) 는 정렬 '깃 (git) 을 사용하여 직접 지사급 소개하십시오 지사급': 참조 [커밋합니다 aa3bc55] (https://github.com/git/git/commit/aa3bc55e408d4daab52239d6b80f7d4bb87f6de7), [커밋합니다 aedcb7d] (https://github.com/git/git/commit/aedcb7dc75e5c260f20bebe14925f3ac4841b03d), [커밋합니다 1511b22] (https://github.com/git/git/commit/1511b22d40d102f397104858a617aa1662bb1c98), [커밋합니다 f65f139] (https://github.com/git/git/commit/f65f13911afa8dd66d163049d91dbfe2ed73717e). (23일 9월 2015년), [커밋합니다 aedcb7d] (https://github.com/git/git/commit/aedcb7dc75e5c260f20bebe14925f3ac4841b03d), [커밋합니다 1511b22] (https://github.com/git/git/commit/1511b22d40d102f397104858a617aa1662bb1c98), [커밋합니다 ca41799] (https://github.com/git/git/commit/ca41799068e101e908544d4e2000a747b1389ebc) (24일 9월 2015년), [커밋합니다 f65f139] (https://github.com/git/git/commit/f65f13911afa8dd66d163049d91dbfe2ed73717e). (23일 9월 2015년) 에서 [카르티크 나약 ('카르티네이아크')] (https://github.com/KarthikNayak). sup> <; (병합되었습니다 에서 [주니우 캜 하마노 기트스터 '-' -] (https://github.com/gitster) 에서 [커밋합니다 7f11b48] (https://github.com/git/git/commit/7f11b485215be205f498fe646a7adc8c8b5386a5), 15일 10월 2015년), /sup> <.
특히 커밋합니다 aedcb7d:
>. # '프란치스코': & # 39, & # 39 ref 필터링합니다 ',' 사용 Api
& # 39, & # 39 프란치스코 만들기 ',' & # 39, & # 39 ref 필터링합니다 ',' 사용 Api 를 통해 반복 참조 정렬. 이렇게 되면 '& # 39, & # 39 에서 사용되는 대부분의 코드를' 프란치스코. 대체하면서 & # 39, & # 39 ref 필터링합니다 대한 호출을 통해 ',' 라이브러리.
그 [추가하므로 정렬 = < key>, 옵션 ','] [2]:
>. 정렬하려면 키를 기준으로 볼 때. '-' 의 값을 내림차순으로 정렬하려면 접두어입니다.
>. ',' 옵션을 사용할 수 있습니다. = < 정렬 key> 여러 번 마지막 주요 되고, 이 경우 기본 키입니다.
>. [단과 깃 (git) '에서' 각 참조] 시동키는 사용할 수 있다. [3]. 기본적으로 모든 정렬 순서를 기준으로 정렬 세나미 을 비롯한 접두어입니다 /. '' 참조). 이 목록은 분리되었는지 헤드입니다 (있는 경우) 에 먼저 국내 지사 및 마지막으로 원격입니다 추적 분기로서의.
여기.
git branch --sort=-committerdate
(아래 참조) 와 깃 (git) 2.19) 또는
# if you are sure to /always/ want to see branches ordered by commits:
git config --global branch.sort -committerdate
git branch
[커밋합니다 9e46833] 참조 (https://github.com/git/git/commit/9e468334b41c1d1fc715de177ef1f61a36c1cf01) (30일 10월 2015년) 에서 [카르티크 나약 ('카르티네이아크')] (https://github.com/KarthikNayak). 의한 도움으로: [주니우 캜 하마노 ('기트스터')] (https://github.com/gitster). sup> <; (병합되었습니다 에서 [주니우 캜 하마노 기트스터 '-' -] (https://github.com/gitster) 에서 [커밋합니다 415095f] (https://github.com/git/git/commit/415095f05501bb17edcb86c6d9fd193753b30ea7), 03일 11월 2015년), /sup> <.
>. 숫자 값을 따라 정렬할 때 (예를 들어 '=' 정렬 개체 크기) 같은 값을 가질 때 대체 비교 참조 모두 없다. 이 예상치 못한 결과를 가져올 수 있습니다 (즉, order of 목록 참조) 와 같은 값을 就不可能拥有 사전에 결정된) 에서 지적한 대로 요하네스 Sixt ($ gmane/280117).
>. 이에 따라 대체 세나미 문숫자 비교, *
$ git branch --sort=objectsize
* (HEAD detached from fromtag)
branch-two
branch-one
master
깃 (git) 2.19, 함께 정렬 순서를 기본으로 설정할 수 있습니다. 깃 (git) '은' like '태그' 깃 (git) ',' 분기로의 구성용 프란치스소르 있는 타g. 소르 구성용 '이미'. 참조 [커밋합니다 560ae1c] (https://github.com/git/git/commit/560ae1c164ad040a389ccc47834dce8c15447294) (16일 8월 2018년) 에서 [새뮤얼 마프툴 (")] (https://github.com/). sup> <; (병합되었습니다 에서 [주니우 캜 하마노 기트스터 '-' -] (https://github.com/gitster) 에서 [커밋합니다 d89db6f] (https://github.com/git/git/commit/d89db6f4c3fceea7bc9e66823c7a04920e95ac1d), 27일 8월 2018년), /sup> <.
>. 프란치스소르:
>. 이 때 '의' 에 표시되는 정렬하려면 가변적입니다 제어됩니다 오더할 분기로서의 git 분기로의. ',' = < " 없이 정렬 value> ";; 제공된 옵션을 이 변수의 값을 기본값으로 사용됩니다.
[2]: https://github.com/git/git/blob/aedcb7dc75e5c260f20bebe14925f3ac4841b03d/Documentation/git-branch.txt # L232-L240 [3]: https://github.com/git/git/blob/f5b6079871904ba5b0a8548f91545f126caf898b/Documentation/git-for-each-ref.txt # L82-L139
깃 (git) 을 사용하여 목록에 원격입니다 분기로서의 '-' boot-r 분기로의 정렬하려면 = 개체 크기. 이 때문에 현지 분기로서의 대신 '-r' 플래깅 원격입니다 분기로서의 나열할 수 있습니다.
내가 좋아하는 상대 날짜 및 납기를 단축할 분기로의 이름을 사용하여 다음과 같습니다.
git for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads
확보할 수 있으므로 출력:
21 minutes ago nathan/a_recent_branch
6 hours ago master
27 hours ago nathan/some_other_branch
29 hours ago branch_c
6 days ago branch_d
내가 좋아하는 앨리어스를 추천합니까 Bash 파일을 만들기 위해 추가 스크립트입니다 아웃해야 그리곤요 공유함을 데이터베이스에구성원을 팀. # 39 의 추가 here& 예로 그냥 이 번호요:
#!/bin/sh
git config --global alias.branches "!echo ' ------------------------------------------------------------' && git for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads && echo ' ------------------------------------------------------------'"
그런 다음 그냥 이렇게 정렬할지 포맷하여 아주 잘 받기 위해 현지 지사 목록:
git branches
업데이트: 이렇게 스케쳐내 색상:
#!/bin/sh
#
(echo ' ------------------------------------------------------------' && git for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads && echo ' ------------------------------------------------------------') | grep --color -E "$(git rev-parse --abbrev-ref HEAD)$|$"
깃 (git) 2.19 vmware. 됩니다.
git branch --sort=-committerdate
수도 있습니다.
git config branch.sort -committerdate
그래서 현재 리포지토리를 나열하십시오 분기로서의 때마다 얻게된다면 나열되며 코미터다테 정렬됩니다.
그 때마다 필요한 경우 나열하십시오 분기로서의 카미스터다테 정렬됩니다.
git config --global branch.sort -committerdate
부인: # 39 m 의 저자, Git, 이 기능을 i& 쉐퍼드도 구현됩니까 봤을 때 내 정보기술 (it) 이 질문이예요
I came up with 다음 명령줄에서는 (깃 (git) 을 위한 2.13 이후).
git branch -r --sort=creatordate \
--format "%(creatordate:relative);%(committername);%(refname:lstrip=-1)" \
| grep -v ";HEAD$" \
| column -s ";" -t
마지막 줄 알 수 없는 경우 '열' 로 바꿀 수 있습니다.
| sed -e "s/;/\t/g"
출력물에는 같은데
6 years ago Tom Preston-Werner book
4 years, 4 months ago Parker Moore 0.12.1-release
4 years ago Matt Rogers 1.0-branch
3 years, 11 months ago Matt Rogers 1.2_branch
3 years, 1 month ago Parker Moore v1-stable
12 months ago Ben Balter pages-as-documents
10 months ago Jordon Bedwell make-jekyll-parallel
6 months ago Pat Hawks to_integer
5 months ago Parker Moore 3.4-stable-backport-5920
4 months ago Parker Moore yajl-ruby-2-4-patch
4 weeks ago Parker Moore 3.4-stable
3 weeks ago Parker Moore rouge-1-and-2
19 hours ago jekyllbot master
내가 작성했습니까 [블로그 포스트] (https://esham.io/2017/07/git-branch-authors) 방법에 대해 다양한 냥이라구 작동합니까.
그래서 내가 쓴 《 루비 컴팩트형 동일한 문제가 경식도 불렀으매 작은 가지. 열거합니다 시간순으로 분기로서의 (최신 첫 번째) 이 있으며, 또한 최대 기간보다오래된 don& 있도록 설정할 수 있습니다, t # 39 모든 분기로서의 목록 (많은 경우 그). 예를 들면 다음과 같습니다.
$ twig
issue status todo branch
----- ------ ---- ------
2013-01-26 18:00:21 (7m ago) 486 In progress Rebase optimize-all-the-things
2013-01-26 16:49:21 (2h ago) 268 In progress - whitespace-all-the-things
2013-01-23 18:35:21 (3d ago) 159 Shipped Test in prod * refactor-all-the-things
2013-01-22 17:12:09 (4d ago) - - - development
2013-01-20 19:45:42 (6d ago) - - - master
또한 각 지점, 예를 들어, 티켓 id, 상태, 사용자 정의 속성을이 저장하는 데 사용할 수 있으며, 이러한 특징에 따르면 토도스 목록을 필터링합니다 분기로서의. 추가 정보: http://rondevera.github.io/twig/
$ git reflog | egrep -io "moving from ([^[:space:]]+)" | awk '{ print $3 }' | head -n5
master
stable
master
some-cool-feature
feature/improve-everything
여기 다른 어떤 다른 모든 스크립트에만 스크립트입니다 높여줍니까 못하며창조된 사실 또한 함수 단축시킵니다 쉘입니다.
깃 (git) 등 몇 가지 색상 중에서 꺼내 기여한 것이 구성 (또는 사용 설정값으로).
# Git Branch by Date
# Usage: gbd [ -r ]
gbd() {
local reset_color=`tput sgr0`
local subject_color=`tput setaf 4 ; tput bold`
local author_color=`tput setaf 6`
local target=refs/heads
local branch_color=`git config --get-color color.branch.local white`
if [ "$1" = -r ]
then
target=refs/remotes/origin
branch_color=`git config --get-color color.branch.remote red`
fi
git for-each-ref --sort=committerdate $target --format="${branch_color}%(refname:short)${reset_color} ${subject_color}%(subject)${reset_color} ${author_color}- %(authorname) (%(committerdate:relative))${reset_color}"
}
#!/bin/bash
# sudo bash
re='^[0-9]+$'
if [[ "$1" =~ $re ]]; then
lines="$1"
else
lines=10
fi
branches="$(git recent | tail -n $lines | nl)"
branches_nf="$(git recent-nf | tail -n $lines | nl)"
echo "$branches"
# Prompt which server to connect to
max="$(echo "$branches" | wc -l)"
index=
while [[ ! ( "$index" =~ ^[0-9]+$ && "$index" -gt 0 && "$index" -le "$max" ) ]]; do
echo -n "Checkout to: "
read index
done
branch="$( echo "$branches_nf" | sed -n "${index}p" | awk '{ print $NF }' )"
git co $branch
clear
이러한 두 가지 사용하여 앨리어스가:
recent = for-each-ref --sort=committerdate refs/heads/ --format=' %(color:blue) %(authorname) %(color:yellow)%(refname:short)%(color:reset)'
recent-nf = for-each-ref --sort=committerdate refs/heads/ --format=' %(authorname) %(refname:short)'
Git 리포지토리를 농구계의 보여줄 수 있는 것 외에도 마지막 ᄂ씨 분기로서의 (10 기본적으로) 와 숫자는 각. 지점 수를 포함하고 있고, 입력 체크 아웃.
이 기반으로 하고 있다 [saeedgnu& # 39 의 버전] [1] 갖추고 있지만, 현재 분기로의 스타가 아무것도 보이지 않는 색으로 표시되어 있으며, 단, months" " 묘사된다. 또는 " years"; 전:
<! - 언어: > 내주었다.
current_branch="$(git symbolic-ref --short -q HEAD)"
git for-each-ref --sort=committerdate refs/heads \
--format='%(refname:short)|%(committerdate:relative)' \
| grep -v '\(year\|month\)s\? ago' \
| while IFS='|' read branch date
do
start=' '
end=''
if [[ $branch = $current_branch ]]; then
start='* \e[32m'
end='\e[0m'
fi
printf "$start%-30s %s$end\\n" "$branch" "$date"
done
[1]: # 17405287 https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit/17405287
[이 수락됨 명령줄이 오토메이티드] [1] 바위, 뭔가 예뻐, 그 같은 gui 를 사용하여 조종됩니다 신앙이니라 운영까지도 " github". =;
&Quot Branches", 클릭할 수 있습니다. 저장소에서의. 또는 직접 url 을 기록했다. https://github.com/ORGANIZATION_NAME/REPO_NAME/branches
[1]: # 5188364 https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit/5188364