Skip to content

Commit fca877b

Browse files
committed
feat: add blog post on enhancing Git workflow with aliases
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent a0e5741 commit fca877b

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
title: "Supercharge Your Git Workflow with Powerful Aliases"
3+
subtitle: "Insights from a visual design intern at Layer5"
4+
date: 2025-01-25 10:30:05 -0530
5+
author: Layer5 Team
6+
thumbnail: ./hero-image.png
7+
darkthumbnail: ./hero-image.png
8+
category: "Engineering"
9+
description: "Git command line aliases and git shortcuts"
10+
tags:
11+
- git
12+
type: Blog
13+
resource: true
14+
published: true
15+
---
16+
17+
import { BlogWrapper } from "../../Blog.style.js";
18+
import { Link } from "gatsby";
19+
20+
<BlogWrapper>
21+
22+
**Tired of typing long Git commands?**
23+
24+
Git is an incredibly powerful tool, but its command-line interface can sometimes feel cumbersome. Fortunately, Git allows you to create custom aliases to simplify your workflow. By assigning short, easy-to-remember names to frequently used commands, you can significantly boost your productivity and reduce the time spent on repetitive tasks.
25+
26+
27+
<div>
28+
29+
<iframe width="100%" src="https://www.youtube.com/watch?v=vkk2jHUgbNQ" loading="lazy" frameborder="0"
30+
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
31+
style="min-height: 315px; min-width: 280px;
32+
"></iframe>
33+
<p>Video: `git lg` alias for a more visually appealing log</p>
34+
</div>
35+
36+
### Why Use Git Aliases?
37+
38+
* **Efficiency:** Quickly execute complex commands with a single keystroke.
39+
* **Consistency:** Reduce the risk of typos and errors in your Git commands.
40+
* **Personalization:** Tailor your Git experience to your specific needs and preferences.
41+
42+
### Essential Git Aliases
43+
44+
Here are some essential Git aliases that can revolutionize your workflow:
45+
46+
**Navigation and Branching:**
47+
48+
* **`git co`:** Quickly switch branches.
49+
```bash
50+
git config --global alias.co checkout
51+
```
52+
* **`git br`:** List all branches.
53+
```bash
54+
git config --global alias.br branch
55+
```
56+
* **`git new`:** Create a new branch and switch to it.
57+
```bash
58+
git config --global alias.new '!git checkout -b'
59+
```
60+
61+
**Staging and Committing:**
62+
63+
* **`git a`:** Stage all changes.
64+
```bash
65+
git config --global alias.a add
66+
```
67+
* **`git cm`:** Commit with a message.
68+
```bash
69+
git config --global alias.cm commit -m
70+
```
71+
* **`git cam`:** Amend the last commit.
72+
```bash
73+
git config --global alias.cam commit --amend -m
74+
```
75+
* **`git ca`:** Stage all and commit with a message.
76+
```bash
77+
git config --global alias.ca '!git add -A && git commit -m'
78+
```
79+
80+
**Viewing and Comparing:**
81+
82+
* **`git st`:** Check the state of your repository.
83+
```bash
84+
git config --global alias.st status
85+
```
86+
* **`git lg`:** View a more visually appealing log.
87+
```bash
88+
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
89+
```
90+
* **`git df`:** Show the diff of unstaged changes.
91+
```bash
92+
git config --global alias.df diff
93+
```
94+
* **`git dc`:** Show the diff of staged changes.
95+
```bash
96+
git config --global alias.dc diff --cached
97+
```
98+
99+
**Undoing Changes:**
100+
101+
* **`git undo`:** Reset the last commit, keeping your changes.
102+
```bash
103+
git config --global alias.undo 'reset HEAD^'
104+
```
105+
106+
**Remote Interactions:**
107+
108+
* **`git fch`:** Fetch all changes from remotes.
109+
```bash
110+
git config --global alias.fch fetch
111+
```
112+
* **`git pl`:** Pull the latest changes from the current branch's remote.
113+
```bash
114+
git config --global alias.pl pull
115+
```
116+
* **`git ps`:** Push your local changes to the remote branch.
117+
```bash
118+
git config --global alias.ps push
119+
```
120+
121+
### Setting Up Git Aliases
122+
123+
To set up these aliases, you can edit your global Git configuration file:
124+
125+
1. **Open your `.gitconfig` file:**
126+
- **Global:** `~/.gitconfig`
127+
- **Local:** `.git/config`
128+
2. **Add the aliases:** Use the `git config` command to add each alias. For example:
129+
```bash
130+
git config --global alias.co checkout
131+
```
132+
133+
### Streamline your cloud native workflow (just like git aliases)
134+
135+
Just as git aliases simplify your development workflow, <Link to="/meshery">Meshery</Link> streamlines the management of your cloud native infrastructure. This CNCF project provides a unified platform to wrangle Kubernetes and other cloud native tools, so you can focus on building and deploying amazing applications.
136+
137+
By incorporating these Git aliases into your workflow, you can streamline your development process, reduce errors, and ultimately become a more efficient developer. Experiment with different aliases to find the perfect combination that suits your needs.
138+
139+
**Happy Git-ing!**
140+
141+
</BlogWrapper>
2.96 MB
Loading

0 commit comments

Comments
 (0)