Add files to Git and track changes
If you have enabled Git integration for your project, IntelliJ IDEA suggests adding each newly created file under version control. You can change this behavior in the Settings dialog Control+Alt+S under Version Control | Confirmation . If you want certain files to always remain unversioned, you can configure Git to ignore them.
You can also add files to your local repository from the Project tool window. Select the files you want to add, and press Command Alt A or choose Git | Add from the context menu.
Check project files status
IntelliJ IDEA allows you to check the status of your local working copy compared to the repository version of the project. It lets you see which files have been modified, which new files have been added to Git, and which files are not being tracked by Git.
Open the Commit tool window Alt+0 .
- The Changes changelist shows all files that have been modified since you last synchronized with the remote repository (highlighted in blue), and all new files that have been added to Git, but have not been committed yet (highlighted in green).
- The Unversioned Files changelist shows all files that have been added to your project, but that are not being tracked by Git.
If you want ignored files to be also displayed in the Changes view, click on the toolbar and select Show Ignored Files .
Track changes to a file in the editor
You can also track changes to a file as you modify it in the editor. All changes are highlighted with change markers that appear in the gutter next to the modified lines and show the type of changes introduced since you last synchronized with the repository. When you commit changes to the repository, change markers disappear.
The changes you introduce to the text are color-coded:
- line added.
- line changed.
- line deleted.
You can customize the default colors for line statuses on the Editor | Color Scheme | VCS page of the IDE settings Control+Alt+S .
To disable VCS markers in the gutter, deselect the Highlight modified lines in gutter option on the Version Control | Confirmation page of the IDE settings Control+Alt+S .
You can manage changes using a toolbar that appears when you hover over a change marker and then click it. The toolbar is displayed together with a frame showing the previous contents of the modified line:

You can roll back changes by clicking and explore the differences between the current and the repository version of the current line by clicking . To highlight the fragments that were changed, click .
Instead of reverting the whole file, you can copy any part of the contents of this popup and paste it into the editor.
Delete files from the repository
If you delete a file that is under version control, it still exists in the repository until you’ve committed the changes. The deleted file is placed in the active changelist and is highlighted in grey.
- Select a file in the Project tool window and press Delete or choose Delete from the context menu.
- In the dialog that opens, you can choose whether you want to delete this file without searching for usages or to perform safe delete (to make sure that you are deleting an unused file) by checking the Safe delete option. If any usages have been found, the Usages Detected dialog will pop up listing them. You can view these usages and remove references to this file before deleting it.
- Commit the changes to the repository.
Add files to Git and track changes
If you have enabled Git integration for your project, WebStorm suggests adding each newly created file under version control. You can change this behavior in the Settings dialog Control+Alt+S under Version Control | Confirmation . If you want certain files to always remain unversioned, you can configure Git to ignore them.
All the settings files in the .idea directory should be put under version control except workspace.xml , which stores your local preferences. The workspace.xml file should be marked as ignored by VCS.
You can also add files to your local repository from the Project tool window. Select the files you want to add, and press Command Alt A or choose Git | Add from the context menu.
Check project files status
WebStorm allows you to check the status of your local working copy compared to the repository version of the project. It lets you see which files have been modified, which new files have been added to Git, and which files are not being tracked by Git.
Open the Commit tool window Alt+0 .

- The Changes changelist shows all files that have been modified since you last synchronized with the remote repository (highlighted in blue), and all new files that have been added to Git, but have not been committed yet (highlighted in green).
- The Unversioned Files changelist shows all files that have been added to your project, but that are not being tracked by Git.
If you want ignored files to be also displayed in the Changes view, click on the toolbar and select Show Ignored Files .
You can perform deployment tasks, such as uploading files and folders or comparing them with deployed versions, directly from the Local Changes tab of the Version Control tool window. To do this, right-click an item and select Deployment from the context menu. Then choose the desired action from the submenu.
The option is only available if the FTP/SFTP/WebDAV Connectivity plugin is enabled and at least one server access configuration is defined.
Track changes to a file in the editor
You can also track changes to a file as you modify it in the editor. All changes are highlighted with change markers that appear in the gutter next to the modified lines and show the type of changes introduced since you last synchronized with the repository. When you commit changes to the repository, change markers disappear.
The changes you introduce to the text are color-coded:
- line added.
- line changed.
- line deleted.
You can customize the default colors for line statuses on the Editor | Color Scheme | VCS page of the IDE settings Control+Alt+S .
To disable VCS markers in the gutter, deselect the Highlight modified lines in gutter option on the Version Control | Confirmation page of the IDE settings Control+Alt+S .
You can manage changes using a toolbar that appears when you hover over a change marker and then click it. The toolbar is displayed together with a frame showing the previous contents of the modified line:

You can roll back changes by clicking and explore the differences between the current and the repository version of the current line by clicking . To highlight the fragments that were changed, click .
Instead of reverting the whole file, you can copy any part of the contents of this popup and paste it into the editor.
Delete files from the repository
If you delete a file that is under version control, it still exists in the repository until you’ve committed the changes. The deleted file is placed in the active changelist and is highlighted in grey.
- Select a file in the Project tool window and press Delete or choose Delete from the context menu.
- In the dialog that opens, you can choose whether you want to delete this file without searching for usages or to perform safe delete (to make sure that you are deleting an unused file) by checking the Safe delete option. If any usages have been found, the Usages Detected dialog will pop up listing them. You can view these usages and remove references to this file before deleting it.
- Commit the changes to the repository.
Как добавить целую папку в Unversioned Files в Intellij Idea?
В качестве системы контроля версий используется Subversion. В окне Changes у меня есть три changelist‘а:
Я хочу перенести файлы из папки Default в Unversioned Files. И я могу перетащить файлы мышкой, но как можно это сделать по-другому? Например, может быть, можно прописать в настройках, какие папки должны находиться в Unversioned Files? В File -> Settings -> Version Control -> Ignored Files 4 папки:
А в Unversioned Files только одна папка, production. Это тоже немного непонятно. Т.е., Ignored Files и Unversioned Files никак между собой не связаны?
Отслеживать
задан 1 сен 2016 в 9:23
10.7k 6 6 золотых знаков 47 47 серебряных знаков 98 98 бронзовых знаков
Для чего вы хотите перенести файлы? Ignore files — изменения этих файлов игнорируются свн, unversioned files — файлы которых нет в свн,
4 сен 2016 в 18:41
@a.chugunov, я хотела добавить её для игнорирования svn
Подключаем Git к Android Studio
Android Studio умеет работать с системами контроля версий (version control system, сокр.VCS). Самой популярной системой является Git, которая стала практически стандартом во многих языках программирования.
Сама по себе Git управляется через командную строку. Для изучения её возможностей есть множество документации. Мы сфокусируемся на подключении Git к проекту в Android Studio.
Чтобы лучше понять объяснения, откройте старый проект Hello Kitty или создайте его заново, если успели его удалить.
Для начала нужно установить Git. Перейдите на страницу загрузки http://git-scm.com/downloads и скачайте последнюю версию под вашу операционную систему.
Запускаем процесс инсталяции. Не рекомендую устанавливать в папку по умолчанию в системной папке Windows C:\Program Files, так как из-за пробела между словами часто возникают проблемы у многих пользователей при работе с командной строкой. Я установил в папке D:\Git. Желательно также прописать путь к папке D:\Git\bin\ в переменной окружения PATH.
Запускаем файл git-bash.exe для запуска консоли. Следует сконфигурировать Git, указав своё имя и электронный адрес, чтобы можно было установить авторство изменений в коде. Вводим по очереди две команды:
Возвращаемся в студию. Выбираем в меню File | Settings и в диалоговом окне в левой части выбираем секцию Version Control | Git. Нажимаем кнопку с многоточием и находим нужный файл на диске.

Для проверки можно щёлкнуть по кнопке Test, вы должны увидеть радостное сообщение в успешном случае. Закрываем окно настроек, применив изменения.

Данная настройка запоминается и в новых проектах этот шаг можно пропустить.
Далее идём в меню VCS | Import into Version Control | Create Git Repository и в диалоговом окне выбираем корневую папку проекта. Для удобства можно сразу нажать на значок студии (третий слева), чтобы сразу переместиться в корневую папку, если окно откроется с другой папкой.

Нажимаем кнопку OK и создаём локальный Git-репозиторий. Под капотом выполняется команда git init.
Как только вы это сделаете, в студии произойдут удивительные изменения. Многие имена файлов в левой панели окрасятся в коричневый цвет.

Коричневый цвет шрифта означает, что файл распознан системой контроля версий на локальном компьютере, но ещё не добавлен в репозиторий. Нам следует подсказать системе об этом.
Но не будем торопиться. При создании локального репозитория студия также создала несколько специальных файлов .gitignore, которые помогают системе контроля версий игнорировать некоторые файлы проекта при изменениях. Один такой файл вы можете найти в корневой папке проекта, а второй в папке app. Можете открыть их любым текстовым редактором. Начнём с файла из корневой папки.
.gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures
Как видим, Git будет игнорировать файл .idea/workspace.xml, который относится к конфигурации самой студии на вашем компьютере и к самому проекту не имеет отношения. Аналогично будет проигнорирован файл local.properties, который является уникальным для каждого компьютера. Можно указывать не только отдельные файлы, но и папки. Например, в списке присутствует папка /build. В эту папку попадают файлы при компиляции. Их нет смысла отслеживать, так как они постоянно меняются, когда вы запускаете приложение для проверки. Все файлы, которые должны быть проигнорированы, выводятся обычным чёрным цветом. Обратите внимание на имя файла local.properties на скриншоте выше.
Кроме чёрного и коричневого цвета, имена файлов могут также выводиться синим цветом (файл изменён), зелёным (новый файл).
При подключении Git в нижней части студии появится новая вкладка Version Control. Откройте её. Сейчас вы видите две секции: Default и Unversioned Files. Секция Default сейчас пуста. При изменении или создании новых файлов они попадут в эту секцию. Секция Unversioned Files содержит файлы, которые ещё не были учтены системой контроля версий.
При создании нового проекта файлы автоматически не учитываются и находятся в секции Unversioned Files. Мы хотим их перенести в репозиторий. В левой части панели находятся две колонки со значками. Найдите значок с изображением папки в скобках (при подведении курсора появится подсказка Group by Directory) и нажмите на неё. Файлы будут сгруппированы, как в проекте. Так проще вам будет понять структуру.

Щёлкаем правой кнопкой мыши на Unversioned Files и выбираем в контекстном меню Add to VCS. Либо можно перетащить мышкой эту секцию на секцию Default. В результате все файлы переместятся и будут учтены системой контроля версий.
После добавления файлов нажмите на значок с зелёной стрелкой вверх и надписью VCS (Commit Changes). Откроется диалоговое окно. В текстовом поле Commit Message введите текст, поясняющий изменения в проекте и нажмите кнопку Commit.

Файлы исчезнут из секции Default и теперь находятся под контролем Git. При изменении файл снова попадёт в данную секцию и вам снова нужно выполнить предыдущую операцию Commit.
Например, откроем файл манифеста и добавим разрешение на работу с интернетом. Файл окрасится в синий цвет. Комментируем изменения в проекте, добавив сообщение Добавлено разрешение на интернет.
Просматривать изменения можно на вкладке Log. Вы можете просматривать коммиты и ветки.
Таким образом мы познакомились с базовыми приёмами работы с Git.
Также вы можете создавать новые ветки, сливать их в одну и выполнять прочие операции.
Естественно, вы можете также выкладывать проект на GitHub или наоборот вносить изменения в локальный проект из удалённого репозитория.
