Files
scripts/git/git combine multiple commits.md
2024-06-18 17:23:34 +03:00

3.0 KiB

git checkout -b review-branch

oldest_commit_hash=$(git log --grep="GAT-4861" --reverse --format="%H" | head -1) git checkout -b review-branch $oldest_commit_hash^

$oldestCommitHash = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 git checkout -b review-branch $oldestCommitHash^

git log --grep="GAT-4861" --format="%H" | xargs -L1 git cherry-pick

git log --grep="GAT-4861" --format="%H" | ForEach-Object { git cherry-pick $_ }

git log --grep="GAT-4861" --format="%H" | ForEach-Object { git cherry-pick $_ --strategy-option theirs } git log --reverse --grep="GAT-4861" --format="%H" | ForEach-Object { git cherry-pick $_ --strategy-option theirs }

git log master --reverse --grep="GAT-4861" --format="%H" | ForEach-Object { git cherry-pick $_ --strategy-option theirs --no-commit if ($LASTEXITCODE -ne 0) { Write-Host "Conflict encountered. Skipping commit $_" git reset --merge } }

git checkout master # Replace 'main' with your default branch name if different git branch -D review-branch

git checkout master # Replace 'main' with your default branch name if different git branch -D review-branch

$oldestCommitHash = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 git checkout -b review-branch $oldestCommitHash^

git log master --reverse --grep="GAT-4861" --format="%H" | ForEach-Object { git cherry-pick $_ --strategy-option theirs --no-commit if ($LASTEXITCODE -ne 0) { Write-Host "Conflict encountered. Skipping commit $_" git reset --merge } }

git diff $(git log --grep="GAT-4861" --format="%H" | tail -n 1)^ $(git log --grep="GAT-4861" --format="%H" | head -n 1) > changes.patch

$firstCommit = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 $lastCommit = git log --grep="GAT-4861" --format="%H" | Select-Object -First 1 git diff $firstCommit^ $lastCommit > changes.patch

Checkout to the parent of the earliest "GAT-4861" commit

$earliestCommitHash = git log --grep="GAT-4861" --reverse --format="%H" | Select-Object -First 1 git checkout -b review-branch $earliestCommitHash^

Apply the patch

git apply changes.patch

search for 'App_Code' in commit msgs

git log --all --grep="App_Code"