DEV Community

Cover image for Streamlining Your Git Commit Workflow: Commands and Handy Aliases ☕
Eduardo Maciel for Woovi

Posted on • Edited on

6 2 1 1 1

Streamlining Your Git Commit Workflow: Commands and Handy Aliases ☕

Git workflows are essential for maintaining a clean and efficient development process.

Whether you’re working solo or collaborating with a team, structuring your commits properly ensures that changes are tracked, conflicts are minimized, and dependencies stay up to date.

Below, I'll break down a common Git commit workflow and explore time-saving aliases to simplify these steps.

A basic Git Commit Workflow to create new code

Workflow

1. If you are not on main, switch to the main Branch

git checkout main  # Or use the alias: gcm
Enter fullscreen mode Exit fullscreen mode

2. Code ... Code ... Code ☕

3. Stash Your Changes

git stash  # Alias: gs
Enter fullscreen mode Exit fullscreen mode

4. Pull Latest Changes

git pull  # Alias: gl
Enter fullscreen mode Exit fullscreen mode

5. Create and Switch to a New Branch

git checkout -b <branch>  # Alias: gcb <branch>
Enter fullscreen mode Exit fullscreen mode

6. Pop stash

git stash pop # Alias: gstp
Enter fullscreen mode Exit fullscreen mode

7. Git Commit

git commit -m "feat(subject): descriptive message"
Enter fullscreen mode Exit fullscreen mode

8. Push Branch to Remote

git push -u origin HEAD && gh pr create --fill --body ''  # Obs: this uses the gh cli
Enter fullscreen mode Exit fullscreen mode

9. Code Review...

10. After merging to main.

git checkout main  # Or use the alias: gcm
git pull  # Alias: gl
Enter fullscreen mode Exit fullscreen mode

Git Aliases Configuration

Add to .gitconfig:

[alias]
    co = checkout
    s = status -sb
Enter fullscreen mode Exit fullscreen mode

Shell Aliases

Add to your shell profile:

alias gs="git stash"
alias gl='git pull'
alias gstp='git stash pop'
alias gcb='git checkout -b'
alias gcm='git checkout main'
Enter fullscreen mode Exit fullscreen mode

In Conclusion

  • Always start from an updated main branch to avoid conflicts
  • Every possible conflict will be solved locally
  • Use dedicated branches for isolated work
  • Keep commits small and focused with clear messages
  • Leverage aliases to save time on repetitive commands

Woovi

Woovi is a Startup that enables shoppers to pay as they like. Woovi provides instant payment solutions for merchants to accept orders to make this possible.

If you want to work with us, we are hiring!


Photo by Deva Darshan on Unsplash

Billboard image

Monitor more than uptime.

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (2)

Collapse
 
dhengghuring profile image
Ridho

Cool

Collapse
 
lusqua profile image
Lucas Aguiar

Cool shell aliases!!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay