[GIT] remote branch 를 마지막 수정 날짜 기준으로 정렬

반응형

들어가며

git remote branch(원격 저장소의 브랜치) 에 대해서 어느 브랜치가 최신인지 확인하고 싶은 경우가 있다.

같은 작업이 발생한 이슈의 경우, 일반적으로 더 최신 브랜치가 적합한 경우가 많기 때문에 이럴 때에는 원격 브랜치를 확인해서 어느 브랜치가 최신인지 알고 싶어한다.

 

명령어

git for-each-ref --sort=-committerdate

 

해당 명령어는 마지막 커밋한 날짜를 기준으로 최신순으로 정렬한다.

521a4230f7af37a33c73e5c0a commit refs/remotes/origin/test
c35bbd646c34f9a57dfdce55 commit refs/remotes/origin/bugfix
553092dfbce61fb996d865d1 commit refs/remotes/origin/design/app-layout
7a6bb39e849c2d68f709dbf8 commit refs/remotes/origin/monitoring
9b5f48ebe128f76032486bd1 commit refs/heads/dev

 

날짜와 시간을 보여주고 싶은 경우에는 추가적으로 옵션을 더해서 사용한다.

  • --format="..." : 날짜와 브랜치 이름을 같이 출력
  • refs/remotes/ : remote 브랜치 목록 대상으로 함
git for-each-ref --sort=-committerdate --format="%(committerdate:iso8601) %(refname:short)" refs/remotes/

 

 

위의 명령어를 실행하면 다음과 같은 결과가 나온다.

2025-04-23 17:10:33 +0900 origin/test
2025-04-22 17:22:29 +0900 origin/bugfix
2025-04-22 15:39:02 +0900 origin/design/layout
2025-04-22 13:32:29 +0900 origin/monitoring
2025-04-22 11:23:19 +0900 origin/dev
2025-04-22 11:01:28 +0900 origin/design/design-system
2025-04-21 13:54:30 +0900 origin/ui-fix

 

 

반응형