# Tutorial: Getting started with Git in IntelliJ IDEA

> **TL;DR**
> Required plugins: Git and GitHub (bundled and enabled by default)

This tutorial will show you how to perform the most popular Git operations in IntelliJ IDEA.

You will learn how to create Git repositories for your projects, share them on GitHub, commit and push changes, create and merge branches, resolve merge conflicts, and investigate the files' history.

## Step 1. Create a new project with a Git repository

In this tutorial, we will create a simple project, share it on GitHub, and perform some Git tasks.

Procedure:

1. Launch IntelliJ IDEA and click New Project on the Welcome  screen.

> **Tip:**
> If you have another project open in IntelliJ IDEA at the moment, select `File | New Project` from the main menu.

2. In the New Project wizard, select the project type from the New Project list (for this tutorial, we will create an Empty Project), specify the name of the project (for example, `gitdemo`), and provide the location path.

Select the Create Git repository option.

![%alt_new_project](https://resources.jetbrains.com.cn/help/img/idea/2026.2/gitdemo_empty_project.png)

3. Click Create. The new project will open in IntelliJ IDEA.

> **Note:**
> IntelliJ IDEA automatically detects if Git is installed on your computer. If the IDE cannot locate a Git executable, it suggests downloading it.

You will get a notification that the local Git repository has been created for your project.

Now that you have created a new project with a Git repository, dedicated tool windows for working with Git become available.

![Git integration enabled](https://resources.jetbrains.com.cn/help/img/idea/2026.2/git_integration_enabled.png)

1.  VCS widget: [manage Git branches](manage-branches.html) and perform basic Git operations.

2.  Commit tool window (`Ctrl+K` (Windows), `⌘ K` (macOS), `⌘ K` (IntelliJ IDEA Classic (macOS)), `⌘ K` (macOS System Shortcuts), `Ctrl+K` (XWin), `Ctrl+K` (GNOME), `Ctrl+K` (KDE), `Ctrl+K` (Emacs), `Ctrl+K` (Sublime Text), `Ctrl+K` (Sublime Text (macOS)), `Ctrl+K` (NetBeans), `Ctrl+Alt+K` (Visual Studio), `⌘ ⌥ ⇧ K` (Visual Studio (macOS)), `Ctrl+K` (Eclipse), `Ctrl+K` (Eclipse (macOS)) or `View | Tool Windows | Commit`): [review the local
changes](adding-files-to-version-control.html) and [commit](#commit_and_push) them to the local Git repository.

3.  Git tool window (`Alt+9` (Windows), `⌘ 9` (macOS), `⌘ 9` (IntelliJ IDEA Classic (macOS)), `⌘ 9` (macOS System Shortcuts), `Alt+9` (XWin), `Alt+9` (GNOME), `Alt+9` (KDE), `Alt+9` (Emacs), `Alt+9` (Sublime Text), `⌘ 9` (Sublime Text (macOS)), `Alt+9` (NetBeans), `Alt+9` (Visual Studio), `⌘ 9` (Visual Studio (macOS)), `Alt+9` (Eclipse), `⌘ 9` (Eclipse (macOS)) or `View | Tool Windows | Git`): [work with the Git log](investigate-changes.html) and [more](version-control-tool-window.html).

> **Tip:**
> In the Commit tool window, there is a list of newly created IDE configuration files (such as `.xml` and `.iml`) and a `.gitignore` file. We will just commit them without working with them directly. While this is standard for personal projects, keep in mind that big teams are often more selective about sharing these files to avoid conflicting settings between developers. For more details, refer to the [official Git Documentation](https://git-scm.com/docs/gitignore) and [Exclude files from version control (ignore)](set-up-a-git-repository.html#ignore-files).

## Step 2. Add files to Git

Once the Git integration is enabled, IntelliJ IDEA shows which files have been modified, which new files have been added to Git, and which files are not being tracked by Git.

To learn how it works, let's create a simple `README.md` file with a short description and add it to Git.

Procedure:

1. In the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) , select the project directory (`gitdemo`).

2. Click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.add.svg) New File or Directory on the tool window toolbar (or press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (NetBeans), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))) and select File from the list.   Name the file `README.md` and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

3. In the dialog that opens, click Add so that Git could start tracking the file.

![Add a new file to Git](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add_file_to_git.png)

Now when you modify this file, IntelliJ IDEA automatically indexes any changes (in other words, adds them to the [Git staging area](https://git-scm.com/docs/git-add)) so that you do not have to do that manually.

> **Tip:**
> If you accidentally close this dialog, you can add the file to Git in the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) : right-click the file and select `Git | Add`.

4. Add the following text to the newly created file:

```MARKDOWN
# Tutorial

This is a tutorial where you will learn how to create Git
repositories from your projects and share them on GitHub.

```

Press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)) to make sure you create a new line in the file after this text. We will use it later to learn how to solve merge conflicts.

![The text has been added to the file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/git_readme_md_added.png)

Now the new file is tracked by Git and is added to the Changes changelist in the  Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) ) .

![Changes changelist with a newly created file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/file_added_to_git.png)

The Changes changelist helps you manage local changes that have not yet been committed to a Git repository. Learn more in [Group changes into changelists](managing-changelists.html).

## Step 3. Commit your project to the local Git repository

Now let's add all the files you want to share to the repository and commit them to save their current state.

Procedure:

1. In the  Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) ) , select the files you want to commit by clicking the checkboxes next to them.

> **Tip:**
> From the  Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) ) , you can also preview added and modified files, use the advanced commit options, add and exclude files from the commit, and [more](commit-and-push-changes.html).

> **Tip:**
> In the Commit tool window, there is a list of newly created IDE configuration files (such as `.xml` and `.iml`) and a `.gitignore` file. We will just commit them without working with them directly. While this is standard for personal projects, keep in mind that big teams are often more selective about sharing these files to avoid conflicting settings between developers. For more details, refer to the [official Git Documentation](https://git-scm.com/docs/gitignore) and [Exclude files from version control (ignore)](set-up-a-git-repository.html#ignore-files).

2. Type a message for your first commit (for example, `Add a new project to Git`):

![Commit message in the Commit tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/commit_message.png)

3. Click Commit.

If you have not used Git on your computer, right before committing your changes IntelliJ IDEA will ask you to enter your username and your email. Git will store this information in `.git/config` in order to assign you as an author to your commits.

IntelliJ IDEA notifies you after a successful commit:

![The Files Commited notification](https://resources.jetbrains.com.cn/help/img/idea/2026.2/committed_file.png)

> **Tip:**
> You can edit your commit message by clicking Edit Commit Message in the notification popup. You can also do the same for any commit using the Git tool window (`Alt+9` (Windows), `⌘ 9` (macOS), `⌘ 9` (IntelliJ IDEA Classic (macOS)), `⌘ 9` (macOS System Shortcuts), `Alt+9` (XWin), `Alt+9` (GNOME), `Alt+9` (KDE), `Alt+9` (Emacs), `Alt+9` (Sublime Text), `⌘ 9` (Sublime Text (macOS)), `Alt+9` (NetBeans), `Alt+9` (Visual Studio), `⌘ 9` (Visual Studio (macOS)), `Alt+9` (Eclipse), `⌘ 9` (Eclipse (macOS))). In the Log tab, select a branch, then right-click the necessary commit and select Edit Commit Message.

## Step 4. Share your project on GitHub

To make your project available for other contributors, you need to publish it to a remote repository, for example, on [GitHub](https://github.com) or on [GitLab](https://about.gitlab.com/). IntelliJ IDEA provides integration with both these platforms . Learn more details in [Manage projects hosted on GitHub](manage-projects-hosted-on-github.html) and [Manage projects hosted on GitLab](clone-gitlab-project.html).

In this tutorial, we will publish our project on GitHub.

> **Note:**
> This functionality relies on the [GitHub](https://plugins.jetbrains.com/plugin/13115-github)  plugin, which   you need to install and enable.   For more information, refer to [Open plugin settings](managing-plugins.html#open-plugin-settings).

Procedure:

1. In the main menu, go to `Git | GitHub | Share Project on GitHub``Git | GitHub | Share Project on GitHub`.

2. In the dialog that opens, you can change the repository name (by default, it is the same as the project name), the name of a remote (by default, `origin`), choose the repository type (public or private), and add some description if needed.

Leave the default values in the Repository name and Remote fields. Select the Private option.

If you are not registered on GitHub, click Add account and then Log In via GitHub.

![The Share Project on GitHub dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add_gh_account.png)

Enter your GitHub credentials in the browser window that opens or create a new account there. When you go back to IntelliJ IDEA, the Share by field will show your account's name.

> **Tip:**
> You can change the GitHub account or add a new one using a token in `Settings | Version Control | GitHub`. Learn more in [Manage multiple GitHub accounts](set-up-a-github-account.html#manage_accounts).

3. Click Share. After the project is successfully published on GitHub, the following notification will appear:

![The repo is shared on GitHub](https://resources.jetbrains.com.cn/help/img/idea/2026.2/github_shared.png)

Click the link in the notification to open the repository on GitHub.

## Step 5. Create a new branch

You may need to create a separate branch, for example, when you are working on a new feature and you don't want your changes to get into the main branch before they are tested.

Procedure:

1. Press `Ctrl+T` (Windows), `⌘ T` (macOS), `⌘ T` (IntelliJ IDEA Classic (macOS)), `⌘ T` (macOS System Shortcuts), `Ctrl+T` (XWin), `Ctrl+T` (GNOME), `Ctrl+T` (KDE), `Ctrl+T` (Emacs), `Ctrl+T` (Sublime Text), `Ctrl+T` (Sublime Text (macOS)), `Ctrl+T` (NetBeans), `Ctrl+Alt+W` (Visual Studio), `⌘ ⌥ W` (Visual Studio (macOS)), `Ctrl+T` (Eclipse), `Ctrl+T` (Eclipse (macOS)) or go to Git | Update Project. In the Update Project dialog that opens, leave the default merge option. Click OK to pull the latest version of the current branch.

![The Update project dialog opens](https://resources.jetbrains.com.cn/help/img/idea/2026.2/git-update-project-popup.png)

2. The VCS widget displays the name of your current branch — `main`. Click it, select the `main` branch in the Local node and then New Branch from 'main'.

![Git branch menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/branch_menu.png)

3. In the dialog that opens, specify the branch name, for example, `new_feature`, and select the Checkout branch option to switch to the new branch right away.

![New Git branch](https://resources.jetbrains.com.cn/help/img/idea/2026.2/new_branch.png)

> **Tip:**
> If there are some uncommitted changes in the current branch, you need to commit, revert, or shelve them before switching to another branch. Learn more in [Switch between branches](manage-branches.html#switch-branches).

Now you are switched to the newly created branch:

![Switched to the new branch](https://resources.jetbrains.com.cn/help/img/idea/2026.2/changed_branch.png)

## Step 6. Make and view the changes

Procedure:

1. Add a new file to the project (for example, `git-features.md`) and click Add when IntelliJ IDEA suggests adding it to Git version control.

After that, open the `README.md` file and replace the existing text with the new description:

```MARKDOWN
# Demo

This is a demo project where you will learn how to commit and
push changes, create and merge branches.

Refer to `git-features.md` to check the list of Git operations.
```

In the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)))  and in the editor tabs, IntelliJ IDEA applies different colors to files: blue to modified, green — to newly added. Moreover, in the gutter area of a modified file, the colored change markers appear next to the modified lines.

![Changes in Editor and Project tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/vcs_changes.png)

2. To review what exactly was changed, click the gutter marker:

![Colored change markers](https://resources.jetbrains.com.cn/help/img/idea/2026.2/change_marker.png)

To view the difference in a separate editor tab, click ![the Show diff icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.vcs.diff.svg) Show Diff for Lines:

![Diff for range](https://resources.jetbrains.com.cn/help/img/idea/2026.2/diff_for_range.png)

3. Go to the  Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) )  to preview all the changes at once. Double-click a file to open the diff view in the editor:

![Local Changes](https://resources.jetbrains.com.cn/help/img/idea/2026.2/local_changes.png)

Learn more in [Investigate changes in Git repository](investigate-changes.html).

## Step 7. Commit and push the changes

In our `new_feature` branch, we have created a new `git-features.md` file and have modified the `README.md` file. Let's commit our changes and push them to the remote repository.

Procedure:

1. In the  Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) ) , select the checkboxes next to both our files, and type the commit message (for example, `Update README.md`).

When typing the commit message, you can use [auto-completion](auto-completing-code.html) for the project file names (`Ctrl+Space` (Windows), `⌃ Space` (macOS), `⌃ Space` (IntelliJ IDEA Classic (macOS)), `⌃ Space` (macOS System Shortcuts), `Ctrl+Space` (XWin), `Ctrl+Space` (GNOME), `Ctrl+Space` (KDE), `Alt+/` (Emacs), `Ctrl+Space` (Sublime Text), `⌃ Space` (Sublime Text (macOS)), `Ctrl+Space` (NetBeans), `Ctrl+Space` (Visual Studio), `⌃ Space` (Visual Studio (macOS)), `Ctrl+Space` (Eclipse), `⌃ Space` (Eclipse (macOS))):

![Completion in the commit message](https://resources.jetbrains.com.cn/help/img/idea/2026.2/commit_completion.png)

Click Commit.

> **Tip:**
> To undo the latest not pushed commit, right-click it on the Log tab of the Git tool window (`Alt+9` (Windows), `⌘ 9` (macOS), `⌘ 9` (IntelliJ IDEA Classic (macOS)), `⌘ 9` (macOS System Shortcuts), `Alt+9` (XWin), `Alt+9` (GNOME), `Alt+9` (KDE), `Alt+9` (Emacs), `Alt+9` (Sublime Text), `⌘ 9` (Sublime Text (macOS)), `Alt+9` (NetBeans), `Alt+9` (Visual Studio), `⌘ 9` (Visual Studio (macOS)), `Alt+9` (Eclipse), `⌘ 9` (Eclipse (macOS))) and select Undo Commit. For more information, refer to [Undo the last commit](undo-changes.html#revert-last-commit).

2. Press `Ctrl+Shift+K` (Windows), `⌘ ⇧ K` (macOS), `⌘ ⇧ K` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ K` (macOS System Shortcuts), `Ctrl+Shift+K` (XWin), `Ctrl+Shift+K` (GNOME), `Ctrl+Shift+K` (KDE), `Ctrl+Shift+K` (Emacs), `Ctrl+Shift+K` (Sublime Text), `⌘ ⇧ K` (Sublime Text (macOS)), `Ctrl+Shift+K` (NetBeans), `Ctrl+Shift+K` (Visual Studio), `⌘ ⇧ K` (Visual Studio (macOS)), `Ctrl+Shift+K` (Eclipse), `⌘ ⇧ K` (Eclipse (macOS)) or select  `Git | Push`  from the main menu to push the changes to the remote repository. The Push Commits dialog opens. Here you can review all the commits to be pushed as well as all the affected files.

Before pushing the changes, you can review the differences for each file. To do this, right-click a file and select ![the Show diff icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.vcs.diff.svg) Show Diff or press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS)):

![Push commits](https://resources.jetbrains.com.cn/help/img/idea/2026.2/push_commits.png)

3. Click Push.

After that, IntelliJ IDEA will push all changes to the remote repository on GitHub.

> **Tip:**
> To revert a pushed commit, right-click it on the Log tab of the Git tool window (`Alt+9` (Windows), `⌘ 9` (macOS), `⌘ 9` (IntelliJ IDEA Classic (macOS)), `⌘ 9` (macOS System Shortcuts), `Alt+9` (XWin), `Alt+9` (GNOME), `Alt+9` (KDE), `Alt+9` (Emacs), `Alt+9` (Sublime Text), `⌘ 9` (Sublime Text (macOS)), `Alt+9` (NetBeans), `Alt+9` (Visual Studio), `⌘ 9` (Visual Studio (macOS)), `Alt+9` (Eclipse), `⌘ 9` (Eclipse (macOS))) and select Revert commit. For more information, refer to [Revert a pushed commit](undo-changes.html#revert-commit).

## Step 8. Merge branches and resolve conflicts

There are several ways how you can apply the changes from one branch to another, such as merging and rebasing the branches, cherry-picking commits, applying separate changes or files. All these methods are described in detail in [Merge, rebase, or cherry-pick to apply changes](apply-changes-from-one-branch-to-another.html).

In this tutorial, you will learn how to merge two branches. We will also make a merge conflict on purpose to learn how to easily resolve merge conflicts using IntelliJ IDEA's merge tool.

Procedure: Merge branches

1. Select the `main` branch in the [Git Branches](#git_branches_menu) widget and click Checkout.

> **Tip:**
> If there are some uncommitted changes in the current branch, you need to commit, revert, or shelve them before switching to another branch. Learn more in [Switch between branches](manage-branches.html#switch-branches).

2. In [step 6](#changes), we have modified the `README.md` file in our `new_feature` branch. Now let's update the text one more time in the `main` branch to simulate a merge conflict:

```MARKDOWN
# Tutorial

This is a test project where you will learn how to work
with the most popular Git operations.
```

Press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)) to make sure you create a new line in the file after this text, as you did in [step 2](#new-line-in-editor). This will help us later with conflict resolution.

3. Commit and push the change as described [in step 7](#commit_and_push). Write a commit message (for example, `Add information about Git tutorial`).

4. In the Local node of the VCS widget, select `new_feature` and click Merge 'new_feature' into 'main'.

![Merge option in the VCS widget menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/merge_into_main_option.png)

Since we have made changes for the same file in different branches, the Conflicts dialog appears.

![Conflicts dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/conflicts_dialog.png)

Procedure: Resolve conflicts

1. In the Conflicts dialog, you have several options to resolve the conflict:

* Accept Yours to keep the changes made in the current branch.

* Accept Theirs to apply the changes from the branch that you want to merge into the current one.

* Merge to resolve conflicts manually in a dedicated dialog.

Click Merge. The Merge Revisions dialog opens:

![Resolve conflict](https://resources.jetbrains.com.cn/help/img/idea/2026.2/merge_revisions.png)

* The left pane called Changes from main shows the read-only changes from the local copy.

* The right pane called Changes from new_feature shows the read-only incoming changes from the `new_feature` branch that we want to merge to `main`.

* The central pane called Result is a fully-functional editor with the results of resolving conflicts.

2. In this dialog, you can accept changes by clicking ![the Apply changes from the left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsLeft.svg)/![the Apply changes from the right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsRight.svg), decline them by clicking ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.remove.svg), and type code in the Result pane in the middle. Learn more in [Resolve Git conflicts](resolve-conflicts.html).

Let's accept one change from `main` from the left pane by clicking ![the Apply changes from the left](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsLeft.svg). As we do not need the changes for the same line that come from `new_feature`, click ![Remove](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.remove.svg) in the right pane in the red conflicting line to discard them.

Click ![the Apply changes from the right](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.diff.applyNotConflictsRight.svg) on the right pane for the remaining non-conflicting changes that come from `new_feature`.

Review merge results in the central pane. The merged text should look like this:

```MARKDOWN
# Demo

This is a test project where you will learn how to work
with the most popular Git operations.

Refer to `git-features.md` to check the list of Git operations.
```

![Conflicts resolved](https://resources.jetbrains.com.cn/help/img/idea/2026.2/conflicts_resolved.png)

3. Click Apply.

IntelliJ IDEA will merge the `new_feature` branch to the `main` branch.

4. Push the changes to the remote repository by pressing `Ctrl+Shift+K` (Windows), `⌘ ⇧ K` (macOS), `⌘ ⇧ K` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ K` (macOS System Shortcuts), `Ctrl+Shift+K` (XWin), `Ctrl+Shift+K` (GNOME), `Ctrl+Shift+K` (KDE), `Ctrl+Shift+K` (Emacs), `Ctrl+Shift+K` (Sublime Text), `⌘ ⇧ K` (Sublime Text (macOS)), `Ctrl+Shift+K` (NetBeans), `Ctrl+Shift+K` (Visual Studio), `⌘ ⇧ K` (Visual Studio (macOS)), `Ctrl+Shift+K` (Eclipse), `⌘ ⇧ K` (Eclipse (macOS)) or selecting  `Git | Push`  from the main menu.

You can review the commits in all branches in the Log tab of the Git tool window (`Alt+9` (Windows), `⌘ 9` (macOS), `⌘ 9` (IntelliJ IDEA Classic (macOS)), `⌘ 9` (macOS System Shortcuts), `Alt+9` (XWin), `Alt+9` (GNOME), `Alt+9` (KDE), `Alt+9` (Emacs), `Alt+9` (Sublime Text), `⌘ 9` (Sublime Text (macOS)), `Alt+9` (NetBeans), `Alt+9` (Visual Studio), `⌘ 9` (Visual Studio (macOS)), `Alt+9` (Eclipse), `⌘ 9` (Eclipse (macOS))):

![The Git Log tab](https://resources.jetbrains.com.cn/help/img/idea/2026.2/git_log_tab.png)

From here, you can also revert commits, cherry-pick changes from one branch to another, and more. Refer to [Log tab](log-tab.html) for more details.

## Step 9. View history

When you work on a project with other people, you may have questions like why, when, and how this file was changed.

Procedure:

In the `main` branch, open the `README.md` file. To find out in which commit these changes came from, do one of the following:

* Right-click the file in the editor or in the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)))  and select `Git | Show History`. The History tab of the Git tool window opens:

![Git file history](https://resources.jetbrains.com.cn/help/img/idea/2026.2/git_history.png)

On this tab, you can view all commits that affected the file and find out in which commit the change of your interest was added.

* In the editor, select a code fragment you want to view history for, right-click the selection, and choose `Git | Show History for Selection`. The History for Selection dialog will open:

![Git history for selection](https://resources.jetbrains.com.cn/help/img/idea/2026.2/history_for_selection.png)

Here you can review all the commits that affected the code selection of your interest.

Find more ways of exploring the Git history in [Investigate changes in Git repository](investigate-changes.html).

## Summary

In this tutorial, you have learned how to:

* [Create a project](#create-test-prj) with a local Git repository

* [Add files to Git](#add-files-to-git) and track changes

* [Commit changes](#add_to_git) to save project states

* [Share your project](#github) on GitHub

* [Create and switch](#new_branch) between branches

* [Merge branches](#merge) and [resolve conflicts](#resolve)

* [View and investigate the history](#view_history) of changes

## Next steps

If you didn't find how to perform some specific Git task in this tutorial, refer to the [Git](using-git-integration.html) guidelines — all the Git operations available from the IDE are described there.

If your project is not under Git, you can still track and manage local changes, roll back to the specific file state, restore deleted files, and more using the [Local History](local-history.html) feature.

