DEV Community

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

Posted on

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. Git Commit

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

7. 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

8. Code Review...

. 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

Top comments (0)