Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Running bash commands with git alias
Gonçalo Morais
Gonçalo Morais

Posted on • Originally published atblog.gnclmorais.com on

     

Running bash commands with git alias

This is a quick tip I learned recently and it allowed me to improve mygit workflow a bit more.

Here’s a new part of my.gitconfig:

[alias]    main=!git checkout main&& git pull--no-tagssync=!git main&& git switch -    fuse=!gitsync&& git rebase main
Enter fullscreen modeExit fullscreen mode

This week I added these three alias to my.gitconfig but, if you notice, they are not “regular” alias.The! at their beginning tells Git that these are not alias to Git commands, but rather bash commands.

This gives you a simple but powerful way to chain executions, so I created three related alias that I can call depending on my goal:

  • If I finished working on a branch and I want to get back tomain and start with the most recent codebase, I’ll rungit main. Notice the--no-tags, this is motivated by working on alarge monorepo and not needing all the tags of the packages we keep updating;
  • If I’m working on a branch and I want to quickly get any changes made to ourmain branch but come back to the branch I’m in right now, I’ll callgit sync. As a note,git switch - gets you back to the branch you were before you moved to the current branch you are now;
  • Finally, if I want to bring the current branch I’m at up to speed with the latest code we’ve shipped, I’ll usegit fuse. It will do everything I described on the other commands so farand rebase ourmain branch onto the current branch I’m at.

Cover image by@yancymin

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

UX Engineer, @recursecenter alumnus, ESTJ. Getting into Ember at the moment, previously Rails and Vue. Runner and climber. I grow a beard most of the time.🤘 light themes 🤘
  • Location
    Nantes, France
  • Work
    Senior Developer
  • Joined

More fromGonçalo Morais

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp