go to article list
Git Branch Updater - Banner
TLDR; I was tired of typing
git switch
,git pull
,git merge
and that shitty repetitive stuff just to update all the dependent branches. I then decided to create a script to ease my git workflow, with just 1 command, you can update and even merge dependent feature branches. e.g.git-branch-updater main/dev/81/82/83/84
You have this huge ticket, then you decide to split it into 3 sub-tasks.
feat/81/task-list
feat/81/sub/82/task-item
feat/81/sub/83/task-list-integrate-with-api
feat/81/sub/84/task-list-tests
Some of them are now in code review, you are now working on the final sub-task, but you have to change something on the first tasks (task-item) due to something you found out suddenly, or a reviewer requested some changes.
Now, you have to edit that feature-branch, then update everything to the last feature-branch just to get the new changes, this is time consuming as you have to switch branches then pull them one-by-one.
I was frustrated just to type those long branch names, so I created a script.
Given the multiple dependent branches earlier:
-> dev # Included this to pull latest changes from dev
-> feat/81/task-list
-> feat/81/sub/82/task-item
-> feat/81/sub/83/task-list-integrate-with-api
-> feat/81/sub/84/task-list-tests
Updating feat/81/sub/84/task-list-tests
from the latest dev
can be tedious. With git-branch-updater
, it's a single command:
$ git-branch-updater dev/81/82/83/84
$ git-branch-updater main/dev/81/82/83/84
-- 1. Fetching branches
-- 2. Convert args to full branch names
---- Getting all branch names (git branch -a)
---- Mapping args to full branch names
Is this the correct list of branches?
-> dev
-> feat/81/task-list
-> feat/81/sub/82/task-item
-> feat/81/sub/83/task-list-integrate-with-api
-> feat/81/sub/84/task-list-tests
Continue? (y/n): y
Continuing...
-- 3. Updating branches to latest change
---- Pulling branch: dev
---- Pulling branch: feat/81/task-list
---- Pulling branch: feat/81/sub/82/task-item
---- Pulling branch: feat/81/sub/83/task-list-integrate-with-api
---- Pulling branch: feat/81/sub/84/task-list-tests
-- 4. Merge dependent branches
---- Merging branch: dev --> feat/81/task-list
---- Merging branch: feat/81/task-list --> feat/81/sub/82/task-item
---- Merging branch: feat/81/sub/82/task-item --> feat/81/sub/83/task-list-integrate-with-api
---- Merging branch: feat/81/sub/83/task-list-integrate-with-api --> feat/81/sub/84/task-list-tests
-- 5. Finished%
This saved me tons of time when encountering this scenario.
--no-merge
: This only pulls the latest changes into its own feature branch, this will not merge dependent branchExample: If you just want to update your local branches (main
, staging
, dev
)
$ git-branch-updater main/staging/dev --no-merge
Release: https://github.com/paolojulian/git-branch-updater/releases/tag/v1.0.0
TAGS:
#git
#workflow
go to article list
Having trouble updating branches that is dependent to one another? Enter git-branch-updater
KEEP IT SIMPLE STUPID! EP1 - Pomodoro
The Right Way to Make Component Variants using Tailwind
Essential Tools and Libraries for Daily Web Development Works
How to Send Emails in Next.js 13 Using the New App API Route
Mastering React Testing: A Comprehensive Checklist of What to Test
Mastering Commit Messages: Best Practices and Examples
How to Integrate Contentful to Next 13
Real-Life Applications of Design Patterns in Your Daily React Code