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

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (2)

Collapse
 
dhengghuring profile image
Ridho

Cool

Collapse
 
lusqua profile image
Lucas Aguiar

Cool shell aliases!!

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay