Fundamentals 11 min read

12 Must‑Know Git Commands Every Intermediate Developer Should Master

This guide presents twelve essential Git commands for intermediate users, explaining configuration scopes, file moving, removal, diffing, resetting, tagging, rebasing, cherry‑picking, bisecting, reverting, fetching, and blaming, each with clear syntax examples and practical notes on their effects.

Liangxu Linux
Liangxu Linux
Liangxu Linux
12 Must‑Know Git Commands Every Intermediate Developer Should Master

git config

The git config command sets configuration values at three levels: local (stored in .git/config of the repository), global (for the current OS user), and system (for all users on the OS). By default it modifies the local level. Common uses include setting the user name, email, default editor, merge behavior, and aliases.

git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global core.editor "vim"
git config --list --show-origin

git mv

git mv

moves or renames a file within the repository, updating both the working directory and the index. The file’s history remains intact, allowing you to retrieve previous versions if needed.

git mv path/to/old_file_name.ext path/to/new_file_name.ext

git rm

git rm

deletes a file from both the working directory and the index. The file’s history is still tracked, so it can be restored later.

git rm path/to/filename.ext

git diff

git diff

shows differences between various states. By default it compares the working tree with the index, but it can also compare branches, commits, or specific files.

git diff branch1 branch2
git diff commitID1 commitID2
git diff commitID1 commitID2 file_to_compare.ext

git reset

git reset

moves the current branch and HEAD to a specified commit. It offers three modes:

soft : only moves HEAD; index and working tree stay unchanged.

mixed (default): resets index but leaves the working tree untouched.

hard : resets both index and working tree, discarding all changes.

git reset
git reset --hard

git tag

git tag

creates a human‑readable reference (usually a version number) that points to a specific commit. Tags are static unlike branches, making them ideal for marking release points.

git tag tag_name

git rebase

git rebase

moves a series of commits onto a new base commit. Without arguments it rebases onto the upstream branch; with a target reference it rebases onto that reference. Adding -i enables interactive rebasing for reordering, squashing, or editing commits.

git rebase origin
git rebase -i HEAD~3

git cherry-pick

git cherry-pick

applies one or more existing commits onto the current branch, allowing selective integration without a full rebase.

git cherry-pick commitID
# Apply a range (excluding the first commit)
git cherry-pick oldest_commit...newest_commit
# Include both ends of the range
git cherry-pick oldest_commit^...newest_commit

git bisect

git bisect

performs a binary search through commit history to locate the commit that introduced a bug. Start with git bisect start, mark the current commit as bad, provide a known good commit, and then iteratively mark each tested commit as good or bad until the offending commit is identified. Finish with git bisect reset.

git bisect start
git bisect bad
git bisect good good_commit_id
# After testing each step:
git bisect bad   # or
git bisect good
git bisect reset

git revert

git revert

creates a new commit that undoes the changes introduced by a specified commit, preserving history without rewriting it.

git revert commitID

git fetch

git fetch

downloads objects and references from a remote repository without merging them into the current branch. It can retrieve all references or those for a specific branch.

git fetch origin
git fetch origin branch_name

git blame

git blame

shows the last modification for each line of a file, indicating the author and commit, which helps trace the origin of specific changes.

git blame path/to/filename.ext

Conclusion

While basic Git usage may not require these intermediate commands, mastering them greatly improves workflow efficiency and gives developers a richer toolbox for solving problems creatively.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GitVersion ControlintermediateCheat Sheet
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.