$repoUrl = "リポジトリのURL" # ここにはクローンしたいリポジトリのURLを指定します
# リポジトリをクローンします
git clone $repoUrl
# リポジトリ名を取得します
$repoName = $repoUrl.Split("/")[-1].Replace(".git", "")
# クローンしたディレクトリに移動します
cd $repoName
# リモートリポジトリの全てのブランチを取得します
git fetch --all
# リモートブランチのリストを取得します
$remoteBranches = git branch -r | foreach { $_.trim() -replace "origin/", "" }
# 各リモートブランチに対してローカルブランチを作成します
foreach ($branch in $remoteBranches) {
git checkout -b $branch origin/$branch
}
# ブランチと最新更新時間を表形式で表示します
$branchInfo = @()
foreach ($branch in $remoteBranches) {
git checkout $branch
$lastCommitTime = git log -1 --pretty=format:"%cd" --date=iso
$branchInfo += New-Object PSObject -Property @{
Branch = $branch
LastCommitTime = $lastCommitTime
}
}
$branchInfo | Format-Table -AutoSize