DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • When Airflow Tasks Get Stuck in Queued: A Real-World Debugging Story
  • Terraform Drift Detection at Scale: How to Catch Configuration Drift Early
  • Git Tags vs AWS Tags: A Tag-Tastic Showdown!
  • GitOps Software Development Principles – And the Benefits for the Entire Organization

Trending

  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • Event-Driven Microservices: How Kafka and RabbitMQ Power Scalable Systems
  • Apple and Anthropic Partner on AI-Powered Vibe-Coding Tool – Public Release TBD
  • The Evolution of Scalable and Resilient Container Infrastructure
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Git Alias: Make Your Git Experience Simpler, Easier, Faster and Clean

Git Alias: Make Your Git Experience Simpler, Easier, Faster and Clean

Make things simpler and easier with these customizable Git shortcuts.

By 
Monzurul Haque Shimul user avatar
Monzurul Haque Shimul
·
Updated Dec. 21, 18 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
13.5K Views

Join the DZone community and get the full member experience.

Join For Free

An alias, or a shortcut, allows us to replace a long or less memorable command with a simple one. In this post, I will talk about Git aliases.

If you use Git on the terminal or command-line, And you don't want to type the entire text of each of the Git commands, you can set up an alias for each command using git config. For example, you may want to set up:

$ git config --global alias.st status


Now instead of typing git status, you just need to type git st to check the status of your Git repository. Here are a couple of more examples you may want to set up:

$ git config --global alias.a add
$ git config --global alias.b branch
$ git config --global alias.c commit
$ git config --global alias.co checkout
$ git config --global alias.cob checkout -b


Another way of adding git aliases is to add it in ~/.gitconfig file. Just open the file with your favorite text editor and add aliases like:

[alias]
    st = status
    a = add
    b = branch
    c = commit
    co = checkout
    cob = checkout -b


Creating a Git alias can also be very useful in creating commands that are missing in Git and that you think should exist. For example, while unstaging a file, you can add your own unstage alias to Git:

$ git config --global alias.unstage 'reset HEAD --'


This makes the following two commands equivalent:

$ git unstage fileA
$ git reset HEAD -- fileA


Obviously, it looks more clean and clearer to use the  git unstage  command than the  git reset HEAD --.

Git alias is not limited for the Git provided commands only. You can also run any external command by adding  !  character at the beginning of it. This is useful when you write your own commands that work with a Git repository. For example, we can make an alias git ui to run gitk or sourcetree :

$ git config --global alias.ui '!gitk'
$ git config --global alias.ui '!sourcetree'

Very much simple! Isn't it?

So far, I have talked about global Git aliases. But you can add repo specific Git aliases too. They are useful to override the global aliases. To add repo specific alias, edit the .git/config file in the repo where you want to add the alias, and follow the same syntax. You can also add them using git config without the --global flag.

That's it for now. Add aliases to your Git repositories as you need them to make your Git experience simpler, easier, faster and clean. I hope you'll find it very useful in your daily Git usages.

Attribution:

Pro Git Book - https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases

Git

Published at DZone with permission of Monzurul Haque Shimul. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • When Airflow Tasks Get Stuck in Queued: A Real-World Debugging Story
  • Terraform Drift Detection at Scale: How to Catch Configuration Drift Early
  • Git Tags vs AWS Tags: A Tag-Tastic Showdown!
  • GitOps Software Development Principles – And the Benefits for the Entire Organization

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!