Fundamentals 7 min read

Master Git in IntelliJ IDEA: A Complete Step-by-Step Workflow

This guide walks you through setting up a remote Git repository, configuring IntelliJ IDEA’s Git integration, cloning a project, initializing and committing code, pushing changes, pulling updates, managing branches, handling merge conflicts, and reviewing commit history, all illustrated with clear screenshots.

macrozheng
macrozheng
macrozheng
Master Git in IntelliJ IDEA: A Complete Step-by-Step Workflow
When using Git, many developers rely on a Git client; IntelliJ IDEA includes one that lets you perform common operations without command‑line Git. This article explains several frequently used Git actions inside IDEA.

Environment Preparation

Install a remote Git repository and a local Git client. See the linked tutorial for details.

Configure the local Git client because IDEA’s Git plugin depends on it.

Operation Process

We use the mall‑tiny project source code to demonstrate a realistic workflow.

Create a project in GitLab and add a README file

Clone the project locally

Open the "Get from Version Control" dialog.

Enter the Git URL to clone.

Do not generate an IDEA project yet because the project is not initialized.

Initialize the project and commit code

Copy the mall‑tiny code into the directory.

Add a .gitignore file to prevent IDE‑generated files from being committed.

# Maven
target/

# IDEA
.idea/
*.iml

# Eclipse
.settings/
.classpath
.project

Open the project with IDEA.

Right‑click the project, choose "Add" to stage all files.

Add a commit message and commit the code.

Push code to the remote repository

Click the Push button.

Confirm the push details.

Verify that the commit appears in the remote repository.

Pull code from the remote repository

Add a README‑TEST.md file in the remote repository.

Pull the changes.

Confirm the branch information.

Create a branch locally and push to remote

Create a dev branch using the Git:master button.

Push the dev branch.

Confirm the push.

Verify that the dev branch now exists remotely.

Switch branches

Switch from dev back to master.

Resolve Git file conflicts

Modify code in the remote repository.

Modify code locally.

Commit locally, pull, encounter conflicts, and click Merge.

Use the arrows to merge changes into the middle pane.

After merging, click Apply.

Commit and push the resolved code.

Merge dev branch into master

Modify dev branch code in the remote repository.

Pull dev branch locally and merge.

Resolve any conflicts, then commit and push.

View Git commit history

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.

GitIntelliJ IDEATutorialVersion ControlbranchingMerge Conflicts
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

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.