SERrex Labs

SERrex Labs

Jun 20, 2023 · 3 min read

Boosting Git Productivity with Handy Aliases

Have you ever wished for quicker and simpler commands while working with Git? Look no further! In this blog post, we'll introduce a collection of Git aliases that can supercharge your productivity and streamline your workflow.

alias ga="git add ."
alias gaa="git add --all"
alias gc="git commit -m"
alias push='git push origin "$(git symbolic-ref --short HEAD)"'
alias pull='git pull --rebase origin "$(git symbolic-ref --short HEAD)"'
alias gs="git status"
alias checkout='git checkout'
alias gclr="git checkout ."
alias gbr='git branch | grep -Ev "(master|main)" | xargs git branch -D'
alias cm="git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' | xargs git checkout"
alias cb="git checkout -"
alias newb="git checkout -b"
alias c="git checkout"
alias repo="gh repo view --web"
alias pr="gh pr view --web"
alias prcheck="gh pr checks --watch"

1. ga - The ga alias is a shorthand for git add .. It allows you to add all changes in the current directory to the staging area with a single command. No more adding files one by one!

2. gaa - Say goodbye to manually tracking changes. With gaa, which stands for git add --all, you can add all changes, including untracked files, to the staging area effortlessly.

3. gc - This alias abbreviates git commit -m and makes committing changes a breeze. Specify your commit message after gc, and Git will take care of the rest.

4. push - Pushing your changes to a remote repository is simplified with push. It automatically detects the current branch and pushes it to the corresponding remote branch, saving you time and effort.

5. pull - Update your local branch effortlessly with pull. It performs a git pull operation with the --rebase option, ensuring a clean and linear commit history.

6. gs - Wondering about the status of your repository? Just type gs, a shorthand for git status, and Git will provide you with the essential information you need.

7. gclr - Made some changes you want to discard? gclr to the rescue! It executes `git checkout .` and reverts the working directory to the last commit, erasing all modifications.

8. gbr - Cleaning up your local branches is a piece of cake with gbr. It intelligently removes all local branches, except for `master` or `main`, ensuring a tidy repository.

9. cm - Switching branches can be tedious, but not anymore. With cm, which stands for git checkout, you can effortlessly switch to the branch specified by refs/remotes/origin/HEAD.

10. cb - Need to quickly switch back to the previous branch? Simply enter cb, an abbreviation for git checkout -, and you're back where you started.

11. newb - Creating and switching to a new branch is now a single command away with newb. Just provide a branch name after newb, and Git will handle the rest.

12. checkout and c - Both `checkout` and `c` are shortcuts for `git checkout`. They provide a convenient way to switch branches without typing the full command.

13. repo - Quickly access the web interface of your current repository using repo. It opens the repository view using the `gh repo view --web` command.

14. pr - Want to review or track a pull request? pr comes to the rescue! It opens the web interface of the current pull request with gh pr view --web.

15. prcheck - Stay updated on the progress of your pull request using prcheck. It uses gh pr checks --watch to monitor the checks and provide real-time feedback.

#Git aliases#git#Efficient Git usage#Git workflow optimization