DEV Community

Discussion on: Improve Your Git Productivity with Bash

Collapse
 
alexparra profile image
Alex Parra

I have lots of git aliases... some in git config and others in bash_profile.
The one I find the most useful is for checking diff of commits between two branches.

But regarding your first alias, I’d like to raise attention that you should review what you’re committing and an alias as you’ve described may prevent less experienced developers from reviewing changes before committing.

There’s another problem with aliases... when you have to work on a machine that’s not yours, you won’t know how... unless you configure your aliases.

I’m not against aliases, I have some myself.
Just sharing concerns for others to see and consider.
Best.

Collapse
 
dalenguyen profile image
Dale Nguyen

Thanks for your concern. I agree that we should check the differences before committing. This step is done after we check everything. We can do it in the editor like VSCode or through the alias: gs and gd.

Collapse
 
oscherler profile image
Olivier “Ölbaum” Scherler

I always use git add -p when I want to commit. It will go through each chunk of changes and ask if I want to add it or not. It’s a great way to review what you are going to commit, spot and skip some leftover debugging code, and it allows you to make smaller commits at the same time.

You can even edit the patch before adding it, which is daunting at first but can be quite convenient to quickly omit a leftover print statement in the middle of an otherwise valid change.