Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 30, 2022 03:21 pm GMT

Improving the DX with Git Aliases

Photo by Roman Synkevych on Unsplash

Improving your DX (developer experience) is a cheaper investment in your career. You can always compose and find better improvements to existing ones.

By focusing on this, you can avoid manual work and get more time to focus on important issues.

In this tiny blog post, let's learn how to improve our developer experience by combining git aliases and the gh cli.

How to know where to improve
Start to look for repeated issues. You are tired of doing every day and every moment with that one.

And using git daily was one of those for me. So, it was time to improve it.

Fewer bits with git aliases
First, I started writing git aliases for the most common commands I was using. My routine was:

git statusgit pull origin maingit checkout -b branch/namegit add file-namegit commit -m "feat(commit): message"git push origin branch/name
  • update main: git pull origin main
  • open a new branch: git checkout -b branch/name
  • add the files git add file-name
  • add the commit message git commit -m "feat(commit): message"
  • push the changes to the origin repo git push origin branch/name
  • go to the git hub on the pull requests page
  • open a new pull request and merge

This routine has many repeated bits for every command and in every new pull request.

So, I decided to create my git aliases:

co = checkoutst = statuscob = checkout -bcim = commit -malias = ! git config --get-regexp ^alias. | sed -e s/^alias.// -e s/\ /\ =\ /pom = pull origin masterpoma = pull origin main

Check my list and how to add it here https://gist.github.com/daniloab/04e45c7f4145ce185c7898a25e25892a

With this change, the flow of creating a new pull request started to have fewer bits but still had room for improvement.

git stgit cob branch/namegit add --agit cim "feat(commit): message"gh pr create --fill

gh cli
Even with the new git aliases, the action to open new pull requests still has the pain of going to the git hub and doing everything to make it possible to open a new pull request.

A cool thing here is that git was also facing the same pain. So then, they created the gh cli, which is a cli to help with git commands.

Then, having my aliases already done, I just need to compose with the gh cli. There are many commands to open new repositories, branches, commit, pull requests, etc. The commands for status, open a branch, and add a new commit were ok with git aliases. I was looking to improve the part of creating a new pull request. And, the git cli could serve this to me with the gh pr create.

https://cli.github.com/manual/gh_pr_create with the flags you prefer.

Then, I just need to open the pr filling with the commit message. The final commands for an open a pull request are:

git stgit pomagit cob branch/namegit add --agit cim "feat(commit): message"gh pr create --fill

Terminal aliases
We can accord that it has fewer bits than the starter commands. But, the gh cli for still a bigger command. Then, I add it to a terminal alias called gcpf:

alias gpcf="gh pr create --fill"

Having the final result as:

git stgit pomagit cob branch/namegit add --agit cim "feat(commit): message"gpcf

gpcf + two enters to type the command and confirm the opening of a new pull request

Always improve
The final result works great for me, I can use them daily and have fewer bits than at the start. But, I can continuously improve and find better solutions.

My next step is to combine the commands of open a branch, add the git message, and open a pull request in one command only. It is not harder, and I just set a little time to do this.

If you have an idea for this, comment below. Also, share it with us if you have an awesome DX for git routine.

Follow me on Twitter
If you like and want to support my work be my patreon
See more in https://linktr.ee/daniloab.


Original Link: https://dev.to/daniloab/improving-the-dx-with-git-aliases-4hb

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To