Master Git Basics and IntelliJ IDEA Integration: A Complete Guide
This article introduces Git as a distributed version control system, explains its core workflow and branch model, and provides step‑by‑step instructions for configuring, cloning, checking out, committing, pushing, and using Git commands within IntelliJ IDEA, including useful screenshots.
1. Git Overview
Git is a popular distributed version control system with local and remote repositories that operate independently unless merging or deleting. Most operations are performed locally, allowing commits and branch switching offline. It uses SHA‑1 hashes to detect corrupted or incomplete file transfers.
Git Basic Workflow
git clone – clone the remote master branch to a local repository.
git checkout – switch to a branch for development.
git add – add files to the staging area.
git commit – commit staged changes to the local repository.
git push – push local commits to the remote repository.
Git Branch Types
Primary branches
master – production‑ready code.
develop – latest development work, merged into master when stable.
Supporting branches
feature – new feature development, merged into develop or discarded.
release – small bug fixes and release preparation.
hotfix – urgent fixes.
2. Using Git in IntelliJ IDEA
2.1 Configure Git
Install Git locally and set up an SSH key.
In IntelliJ IDEA go to Settings → Version Control → Git, set the path to the Git executable and test the connection.
2.2 Clone a Repository
Use VCS → Git → Clone, enter the remote URL and test it.
2.3 Checkout a Branch
In the lower‑right corner of IDEA, select the desired branch to checkout. The UI shows local (1) and remote (2) versions.
2.4 View Differences
In Local Changes, right‑click a file and choose Show Diff; use Revert to discard changes.
2.5 View Commit Log
Open Version Control → Log to see the commit history.
2.6 Commit Changes
Modify files (e.g., pom.xml); they appear under Local Changes. Click the commit icon, write a message, and commit to the local repository.
2.7 Push to Remote
Use VCS → Git → Push to upload local commits.
2.8 Git Commands in IDEA Terminal
Press Alt+F12 to open the terminal. Common commands: git clone, git status, git checkout -b -t origin/ , git pull, git commit -am "msg", git merge , git push.
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.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
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.
