Manage projects hosted on GitHub
You can clone a repository that you want to contribute to directly from IntelliJ IDEA and create a new project based on it.
From the main menu, choose Git | Clone . If the Git menu is not available, choose VCS | Get from Version Control .
In the Get from Version Control dialog, choose GitHub on the left.
Log in to GitHub by doing one of the following:
If you have a token, click Use token , then paste the token in the Token field, and click Log In .
Otherwise, click Log In via GitHub .
Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.
Select a repository from the list of all GitHub projects associated with your account and the organization that your account belongs to.
In the Directory field, enter the path to the folder where your local Git repository will be created.
If you want to create a project based on these sources, click Yes in the confirmation dialog. IntelliJ IDEA will automatically set Git root mapping to the project root directory.
Share a project on GitHub
You can add a remote GitHub repository for a project you are developing locally, so that others can view it or contribute to it.
Open the project you want to share.
From the main menu, choose Git | GitHub | Share Project on GitHub .
If you have already registered your GitHub account in IntelliJ IDEA, connection will be established using these credentials.
If you have not registered your account in IntelliJ IDEA, the Login to GitHub dialog opens. Specify your access token or request a new one with your login and password.
When connection to GitHub has been established, the Share Project on GitHub dialog opens. Specify the new repository name, the name of the remote , and enter a description of your project.
You can select the Private option if you do not want to allow public access to your repository for other GitHub users.
Click Share to initiate a new repository and upload project sources to it.
Jump to the GitHub version of a file
You can jump from IntelliJ IDEA to the GitHub version of a file. IntelliJ IDEA detects which branch is currently active as well as the latest revision of the file, and opens the GitHub copy of the selected file in the corresponding commit in your web browser.
Do one of the following:
Select Git | GitHub | Open on GitHub from the main menu.
Select a file in the editor or in the Project view, and choose Open In | GitHub from the context menu.
Select the file in the Project view, press Ctrl+Shift+A , and type Open on Github .
If you are signed in to GitHub, the remote version of the file will open in the browser.
Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.
If you are opening the GitHub file version from the editor, the file will be also automatically scrolled to the current line.
If the file points to more than one remote, you will be prompted to select the appropriate repository.
Cloning a Project
The first thing we need to do is to clone the repository to our local machine. You need to navigate to the code in GitHub that you want to clone to IntelliJ IDEA. In this tutorial we will use the intellij-samples project.
When you press the green Code button, you can see that there are a few ways to do this. We're going to use HTTPS as it can be the simplest option. From the HTTPS tab, click the clipboard icon, this copies the URL to your clipboard.
Now you've got the link from GitHub, you need to open IntelliJ IDEA. If you don't have any projects option, you'll see the Welcome Screen. You will see an option here to Get from Version Control (or similar depending on the version of IntelliJ IDEA). If you do have a project open already, you can do the same action from the File > New > Project from Version Control menu. In older versions of IntelliJ IDEA, you can also use go to VCS > Get from Version Control. This menu option was renamed to Git > Clone in newer versions (when you have an existing Git project open).
When you press this button, you will get an option to select your Version Control location, GitHub in this instance, and then to enter the URL that's on your clipboard into the URL field.
Press Enter or Clone to clone the GitHub repository to the directory you selected. IntelliJ IDEA will also pick up common build tools like Gradle or Maven, and automatically download the required dependencies and build the project.
When you open up the project window, you'll also see that IntelliJ IDEA has detected the modules in the project, and correctly set up the test, main and resources folders in a Maven project like this one.
Name already in use
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Настройка Git и GitHub в Intellij IDEA
1. Добавить аккаунт GitHub в Intellij IDEA
1.1 Создать access token

Перейди в настройки GitHub -> Developer Settings -> Personal access token -> Generate new token

Оставьте только scope’ы: repo, workflow, read:org и gist.
Появится токен. Обязательно скопируйте его, потому что после того, как вы закроете страницу, он пропадёт!
1.2 Добавить аккаунт в Intellij IDEA
Зайдите в Intellij IDEA. Там File->Settings->Version Control->GitHub.

Там уже нажмите Ctrl+N(на Mac Cmd+N)->Login with token. И просто вставьте ваш скопированный токен в поле. Add account. Поздравляю, вы добавили GitHub аккаунт!
2.1 Скачать проект с GitHub
Для того чтобы клонировать проект, достаточно зайти в File->New->Project from Version Control.

Теперь достаточно выбрать проект и нажать Clone.
2.2 Сделать Commit
Достаточно нажать Git->Commit. Откроется вкладка Commit.

В Unversioned Files находятся файлы не добавленные в staging area. Там можно их добавить, чтобы они попали в следующий коммит. В Changes можно убрать файлы, которые не должны попасть в следующий коммит.
Когда файлы выбранный, можно написать сообщение для коммита и сделать его, нажав кнопку Commit.
2.3 Сделать Push
Это можно сделать из той же вкладки, нажав Commit and Push, после чего файлы загрузятся на удалённый репозиторий.
Так же это можно сделать перейдя Git->Push

В открывшемся окне можно выбрать необходимые коммиты и запушить их на удалённый репозиторий.
2.4 Загрузить через Fetch
Fetch безопасен всегда, поэтому его можно использовать когда угодно. Он просто загружает все изменения с удалённого репозитория, не делая merge с локальным репозиторием. Т.е. загруженные изменения не применятся, а останутся в отдельных ветках, расходящихся с вашими на последнем запушеном коммите.
Подходить, если вам нужно сделать Merge с изменениями из-вне вручную.
2.5 Загрузить через Pull
Pull работает только, если можно сделать fast-forward merge для веток с одинаковыми названиями в удалённом репозитории и в локальном.

В окне можно выбрать ветку, которую надо обновить из удалённого репозитория. Если удалённых репозиториев несколько, то их тоже можно выбрать.
Так же там можно добавить специальные опции, но они требуют отдельного объяснения.
Как загрузить проект с github в intellij idea
In this blog, we’re going to look at how to create an IntelliJ IDEA project from existing code in a GitHub repository.
This blog post covers the same material as the video with some additional tips and tricks. This provides an easy way for people to skim the content quickly if they prefer reading to watching, and to give the reader/watcher code samples and links to additional information.
Clone a GitHub Repository to Our Local Machine
The first thing we need to do is to clone the git repository to our local machine. In the video, we used this IntelliJ samples repository, but it could be one of your repositories if you prefer.
There are several ways to clone a Git repository to your local machine. You can use HTTPS or SSH, amongst other options. Let’s use HTTPS as it can be the simplest option. When we click the clipboard icon, the URL will be copied to our clipboard.

If you don’t have any projects open when you first start IntelliJ IDEA, you’ll see a welcome screen. The welcome screen varies from version to version, the video uses the welcome screen in IntelliJ IDEA 2020.3. Regardless of your version, you’ll have an option to get a project from version control. Clicking on this gives us the Get from Version Control dialog. You can paste the repository URL into the URL input box that we copied from the repository earlier. You can also change the directory that this project is created in on your machine if required.

You can then press Enter, or click Clone, and IntelliJ IDEA will clone the GitHub repository to the directory we selected. IntelliJ IDEA will also pick up common build tools like Gradle or Maven, and automatically download the required dependencies before building the project for you. IntelliJ IDEA will also detect the modules in the project, and correctly set up the test, main and resources folders in a Maven project like the one in the video. You an see the result in the Project window.
There’s more than one way to clone a GitHub project from inside IntelliJ IDEA. If we already have a project like this one open, we can choose to get a new project from GitHub using the VCS menu and selecting Get from Version Control… in version 2020.2, or Clone in version 2020.3. This gives you the same dialog we saw earlier allowing you to enter a URL and project directory.
Tip: You can also use the JetBrains Toolbox extension to clone a GitHub project to IntelliJ IDEA.
Git Tool Window
One of the most useful tools when we’re working with a Git project in IntelliJ IDEA is the Git Tool Window. This gives us visibility over the version control status of our project. One way to open the Git Tool window is to hover over the quick access button in the bottom left of the IntelliJ IDEA window, and select Git. This will open the Git log window.

Alternatively, we can use ⌘9 on macOS, or Alt and 9, on Windows and Linux, to open the Git Tool window. This window shows us all the commits for the project. It also shows us a list of local branches, which in our case is just the “main” branch since we just cloned this repository, as well as remote branches. If you find a visual representation of the commit history useful, this window can help you to understand the status of commits, branches, and remotes for your project.

Tip: The Git tool window means you don’t need a third-party application to manage your Git workflow. The Git Tool window means can perform a variety of tasks including merging, creating a new branch, checking out a branch, and undoing changes.
Adding and Updating Remotes
When we’re working with open source projects on GitHub, it’s common to have more than one remote associated with a repository. If we go back to the intellij-samples project that we cloned from GitHub, we can see that this is actually a fork of another repository hosted by JetBrains.

This upstream repository is in the JetBrains organisation, and is likely to be updated by multiple people at a different rate to the fork we cloned. Ideally we want visibility of the upstream repository as well as our own fork in order to get a better idea of what changes have gone in to the upstream repository, and to update our own fork with these changes. To add this upstream repository remote, we first need to copy the URL like we did before.
We can manage our remotes in IntelliJ IDEA in a couple of different ways. One way is to use Shift+Shift to bring up the Search Everywhere dialog and type Remotes. One of the search results is the ‘Manage Remotes’ option from Git. Selecting this brings up the Git Remotes dialog. This dialog shows the remote we originally cloned this project from, which is our fork of the intellij-samples repository. We want to add a new repository for the upstream repository, in this case, the original JetBrains repository.
When we press the plus button, we can paste in the path to the JetBrains repository that we copied earlier, and give it a name. There are a number of different conventions that you could use to decide on the name for your remote, for example you could call it “upstream”. I like to use the organisation or profile name to remove any ambiguity. You can also use this dialog to make changes to our existing remotes, for example, we can rename the “origin” remote to “trishagee”, because that makes it clearer to me where this remote is pointing. Now when we look at the Git Tool window, it’s clearer which remote the remote branches belong to.

Like most features in IntelliJ IDEA, there’s more than one way to open the Manage Remotes dialog. You can also right-click on the Remote node in the Branches tree of the Git Log, and select Manage Remotes.

Git Fetch
The last thing we’re going to look at is why and how to invoke a Git fetch in IntelliJ IDEA. We just added a new remote to this project, but it’s not showing in the Git Tool window. This also means that none of its branches or commits are visible because we haven’t fetched the status of the new remote to our local project.
We can select VCS > Git > Fetch in version 2020.2 and Git > Fetch in version 2020.3. When we select this, IntelliJ IDEA will fetch all the relevant details from all the git remotes we have configured for the project, and update our Git Tool log window with these details.

Now we can see a new remote in the Git Tool log window, and we can see all this remote’s branches. We will also be able to see the remote’s branches in the commit list. This gives us a clear idea of which commits are on which branches, and if any branches need updating. Another way of performing a Git fetch is to click the Fetch All Remotes button on the Branches tree toolbar in the Git Log window. This will also update the project.
Now we have a fully configured IntelliJ IDEA project from a GitHub repository, with all the relevant remotes added, and a Git Tool log window that shows the current status of the remote repositories. We’re ready to start making changes to this project and to commit, push, and create pull requests.