Compare commits
2 Commits
59bbda7189
...
6d590673ae
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d590673ae | |||
| 89c7782768 |
29
tools/finish-feature.sh
Executable file
29
tools/finish-feature.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 在 feature 分支上执行:合并到 main、推送、删除本地和远端分支
|
||||||
|
# 用法:bash tools/finish-feature.sh
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BRANCH=$(git branch --show-current)
|
||||||
|
if [[ ! "$BRANCH" =~ ^feature/ ]]; then
|
||||||
|
echo "❌ 当前分支不是 feature/*:${BRANCH}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||||
|
echo "❌ 工作区有未提交改动,先提交或暂存"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "== 合并 ${BRANCH} → main"
|
||||||
|
git checkout main
|
||||||
|
git pull --ff-only origin main
|
||||||
|
git merge --no-ff "$BRANCH" -m "Merge branch '${BRANCH}'"
|
||||||
|
git push origin main
|
||||||
|
|
||||||
|
echo "== 清理分支 ${BRANCH}"
|
||||||
|
git branch -d "$BRANCH"
|
||||||
|
if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
|
||||||
|
git push origin --delete "$BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ 已合并并清理 ${BRANCH}"
|
||||||
Reference in New Issue
Block a user