Git bisect 연습 자료 Git과 python 명령이 필요해요. 빈 연습 폴더의 PowerShell에서 아래 코드를 복사해 실행하세요. git-bisect-practice라는 새 폴더만 만들며, 같은 이름이 있으면 중단해요. good-demo는 3000과 종료 코드0, 마지막 커밋은 1003과 종료 코드1을 반환해요. 커밋 해시는 실행 시점에 따라 본문 화면과 달라져요. 마지막 출력 뒤에는 git bisect start HEAD good-demo부터 본문을 따라 하세요. --- 아래 코드 시작 --- $ErrorActionPreference = 'Stop' $practicePath = Join-Path (Get-Location).Path 'git-bisect-practice' if (Test-Path -LiteralPath $practicePath) { throw 'git-bisect-practice already exists. Choose a new empty parent folder.' } $null = New-Item -ItemType Directory -Path $practicePath Set-Location -LiteralPath $practicePath function Invoke-PracticeGit { & git @args if ($LASTEXITCODE -ne 0) { throw 'Git command failed. Stop and inspect the output.' } } Invoke-PracticeGit init -b main Invoke-PracticeGit config --local user.name 'Git Practice' Invoke-PracticeGit config --local user.email 'practice@example.invalid' Invoke-PracticeGit config --local commit.gpgsign false Invoke-PracticeGit config --local core.autocrlf false $utf8 = New-Object System.Text.UTF8Encoding($false) function Save-PracticeText($name, $content) { [IO.File]::WriteAllText((Join-Path $practicePath $name), $content, $utf8) } $goodCode = "def total(price, count):`n return price * count`n" $badCode = "def total(price, count):`n return price + count`n" $testCode = "from runpy import run_path`nvalue = run_path('app.py')['total'](1000, 3)`nprint(f'total(1000, 3) = {value}; expected 3000', flush=True)`nraise SystemExit(0 if value == 3000 else 1)`n" Save-PracticeText 'app.py' $goodCode Save-PracticeText 'check_total.py' $testCode Save-PracticeText '.gitignore' "__pycache__/`n" Save-PracticeText 'README.md' "Price example`n" Invoke-PracticeGit add . Invoke-PracticeGit commit -m 'Initial files' Invoke-PracticeGit tag good-demo & python -B check_total.py if ($LASTEXITCODE -ne 0) { throw 'The initial version must return 3000 with exit code 0.' } Save-PracticeText 'README.md' "Price example with quantity`n" Invoke-PracticeGit commit -am 'Document quantity' Save-PracticeText 'app.py' $badCode Invoke-PracticeGit commit -am 'Change total calculation' Save-PracticeText 'app.py' ("# Calculate order total`n" + $badCode) Invoke-PracticeGit commit -am 'Describe total function' Save-PracticeText 'README.md' "Price example with quantity and total`n" Invoke-PracticeGit commit -am 'Document total output' Save-PracticeText 'README.md' "Price example ready for release`n" Invoke-PracticeGit commit -am 'Prepare release' & python -B check_total.py if ($LASTEXITCODE -ne 1) { throw 'The final version must return 1003 with exit code 1.' } Write-Host 'Practice repository ready. Follow the bisect article from git bisect start HEAD good-demo.' Invoke-PracticeGit status --short --- 코드 끝 ---