Skip to content

Commit 6af24e4

Browse files
committed
git parent-branch && git update-parent-branch custom commands where added
1 parent 26e9a95 commit 6af24e4

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/tmp
2+
tmp
23
Gemfile.lock

bin/git-parent-branch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Detect the base or parent remote branch (best guess)
3+
git log --pretty=format:'%d' --abbrev-commit --decorate-refs-exclude=refs/tags | grep origin | head -2 | tail -1 | sed '1s/tag:[^,]*, //g' | sed -nr '1s/.*\(([^,]+),?.*/\1/p' | cut -d ')' -f 1 | cut -d '(' -f 1

bin/git-update-parent-branch

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Detect the base or parent branch
3+
CURRENT_BRANCH=$(git current-branch)
4+
PARENT_BRANCH=$(git parent-branch)
5+
COMMIT_LIST=$(git rev-list $CURRENT_BRANCH...$PARENT_BRANCH)
6+
7+
git checkout -b $CURRENT_BRANCH-temp
8+
git fetch
9+
10+
git checkout $PARENT_BRANCH
11+
git branch -D $CURRENT_BRANCH
12+
git checkout -b $CURRENT_BRANCH
13+
14+
set -- junk $COMMIT_LIST
15+
shift
16+
for commit_id; do
17+
git cherry-pick "$commit_id"
18+
done
19+
20+
git push --set-upstream origin -f $CURRENT_BRANCH
21+
22+
git log --oneline --color --decorate --graph --all

0 commit comments

Comments
 (0)