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.
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-origingit mv
git mvmoves 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.extgit rm
git rmdeletes 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.extgit diff
git diffshows 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.extgit reset
git resetmoves 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 --hardgit tag
git tagcreates 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_namegit rebase
git rebasemoves 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~3git cherry-pick
git cherry-pickapplies 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_commitgit bisect
git bisectperforms 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 resetgit revert
git revertcreates a new commit that undoes the changes introduced by a specified commit, preserving history without rewriting it.
git revert commitIDgit fetch
git fetchdownloads 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_namegit blame
git blameshows 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.extConclusion
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
