You don’t want to waste time manually typing out long commands every time you use Git version control.
Let’s turn this common command:
git push origin master
If you don’t have a
.gitconfig already, open up your Terminal and run this command:
You should now have an empty
.gitconfig file at
Now open your
.gitconfig file with this command:
You might already have some configuration in this file, such as:
[user] email = email@example.com name = John [github] user = username
If you don’t, I suggest you add it to your gitconfig file now (using your own information).
Now let’s create a git alias for
git push origin master.
Move to a new line and add this:
[alias] pom = push origin master
.gitconfig file should look similar to this:
[user] email = firstname.lastname@example.org name = John [github] user = username [alias] pom = push origin master
Now when you run
git pom in your Terminal, it will automatically run
push origin master for you.
You can use this blueprint to create all types of alias/shortcut commands for Git. For example, let’s say you want to use
git s instead of
git status. Simple, just add it below your other aliases:
[user] email = email@example.com name = John [github] user = username [alias] pom = push origin master s = status
Less typing is always good!