Ship faster with Graphite - Improve dev velocity 

What is the most precious thing about being a developer? Is it the intelligence or the knowledge? I reckon it's time. Because if you can do more in less time that's a win.

What if I told you there was a tool that can slash through your repetitive tasks and free you to focus on the code that matters. 

Example 1: You have  to migrate a component from View based to Jetpack Compose. This will need following workflow:

Example 2: You are building an MVVM android app.

In this workflow, you can start in any order, however you don't want to wait and do nothing while the Data layer PR is in review. You still wanna go ahead and build that awesome UI your design team has built in Figma coz you're too eager to build it. Bonus: This UI is also new to design system and other teams will also use it in the future, so you are going nuts.

We make 3 branches from main as follows:
main ----feature1/data----feature1/domain----feature1/UI

Now what If:

Now it's very tempting for engineer to think, there are too many issues so let's wait for Data Layer to be final and then start other work. BUT,  What If, your awesome colleague told you that there is a place on earth where you go and these issues will look so simple and silly that you'll no even think about it before making 3, 5, or even 10 branches. 

Introducing Graphite.dev

Graphite helps you create smaller pull requests, stay unblocked, and ship faster. Let's look at some advantages of Graphite and then we'll dive into the workflow that I use while creating PR's.

My workflow

Install Graphite from Homebrew ███████▒▒▒ 70%

brew install withgraphite/tap/graphite

gt --version

Authenticate with CLI ᕙ(  •̀ ᗜ •́  )ᕗ 

Installing & authenticating the CLI | Graphite Docs

Initialize Graphite for your repository

gt repo init

# Would you like to start tracking existing branches to create your first stack? › (y/N)

Checkout a branch

gt checkout main

OR

gt co main

Build something cool 🛠️


Feature Part - 1

# add all unstaged change (same syntax as git add)

gt add -A


# Single command to Commit and Create Branch

gt create -m "Commit message" branch_name


# Automatic branch name

gt create -m “Commit message”


# Shorthand Alias

gt c -m "Commit message"


Feature Part - 2

# Build cool feature Part-2

gt add -A


# New Branch in Town

gt c "Cool Feature Part2"

Where am I (view log)?  📍

gt log # view stack of branches


# Alias

gt l


gt ll # log long


gt ls # log short - the one I use the most.


# Upside Down Log (Cake)

gt l --reverse

How to navigate (switch branches) ? 🚗

gt u # gt up


gt u 2 # Let’s Jump ┏(❛̃ ͜ʖ❛̃)┛


gt d # gt down


# Not sure, which branch to navigate to? Let’s choose.   👈 / 👉

gt co # gt checkout


? Checkout a branch (autocomplete or arrow keys) ›

pp--06-14-part_3

pp--06-14-part_2

❯   pp--06-14-part_1

main


# To the top or down the hill  🚁 🪂

gt t # gt branch top

gt b # gt bottom

Can I make a PR using Graphite ? (▀ ̿ĺ̯ ▀̿ ̿)

gt ss # gt stack submit - Create / Update PR's


# Comments on PR ? Let’s make an update.

# Make the changes

gt add -A # Add all unstaged changes


gt m # gt  modify


gt m -c # gt modify commit


gt ss # stack submit - Update PR's

Wanna update to latest trunk?

gt sync # gt sync. Pull latest master and update stack automatically.

# It’s magic. ✧ 


# Master already up to date, Just restack ?

gt r # gt restack


# Restack only current branch

gt restack # - restacks only the current branch onto its parent

Fold two branches. ¯\_(ツ)_/¯

gt fold - (combines) the current branch into its parent

Can this be two PRs? (◑_◑)

gt sp # gt split --by-commit 

gt move  # Select the base branch

Rebase the current branch onto the target branch and restack all of its descendants


gt redorder # Manually reorder branch names by typing


gt pop # Delete the current branch but retain the state of files in the working tree

gt rename [name] # Rename a branch

gt trunk # Checkout main / trunk branch


Resolve Conflicts

gt add -A

gt cont # gt continue

Not reinventing the wheel 𖥞

git add

git stash

git diff

git status # gt status



# Thank You


Trust me once you are comfortable with Graphite, it will save a huge amount of time and what's more precious than saving those couple minutes a day just trying to make sure your branch is up to date. Nah! We've got Graphite.dev