git tips & tricks

9 Useful Git Commands for programmers

Jason Zhang
5 min readMay 29, 2022

--

There is no doubt that Git became the most popular and best version control system available. As a programmer, you use it almost every day.

In this article, I will share my favorite 9 useful git commands with you, based on my programming experiences. This article is not a Git manual or guide, and most of the basic Git commands, such as git init, git add … , can be done through your IDEs like VS Code, and JetBrains. These commands totally based on practical scenarios, and these are the commands I use frequently.

I will demonstrate these commands using VS Code and built-in Terminal.

1. Rename a File

2. The correct way to delete files in Git

3. Modify the message of the latest commit

Input command git commit --amend in your terminal and modify the commit message in the vi editor. After the modification is done, use wq! to exit vi, check the git log, and the message is updated.

4. Handling Emergency tasks

5. Typo

Main Scenarios: When you found a small mistake like a typo, wrong symbol, or missing space…, in your code that just committed in your personal workspace. You can use git add. and git commit --amend--no-edit to fix it directly without generating a new commit.

--

--

Jason Zhang

Software Engineer, Kaggle Competitions Expert