Shelve changes git что это

Git Stash против Shelve в IntelliJ IDEA

Например, в Update Project (из меню VCS)

Shelve changes git что это. u0UO4. Shelve changes git что это фото. Shelve changes git что это-u0UO4. картинка Shelve changes git что это. картинка u0UO4

Один получит (в IntelliJ IDEA 2019.2)

Shelve changes git что это. US0hp. Shelve changes git что это фото. Shelve changes git что это-US0hp. картинка Shelve changes git что это. картинка US0hp

5 ответов

git shelve не существует в Git.

У вас был старый проект 2008 года git shelve для изоляции изменений в ветке, но это не было бы очень полезно в наши дни.

Как описано в диалоговом окне полки Intellij IDEA, функция «стеллажи и расстановка стеллажей «не связаны с VCS ( Инструмент системы контроля версий), но для самой среды IDE, для временного хранения ожидающих изменений, которые вы еще не зафиксировали в списке изменений.

Я бы предпочел отложить изменения, а не хранить их, если я не передаю свои изменения где-либо еще.

Shelve changes git что это. bwKYZ. Shelve changes git что это фото. Shelve changes git что это-bwKYZ. картинка Shelve changes git что это. картинка bwKYZ

Как видите, я могу указать, какие файлы / строки нужно разместить на моей полке. Обратите внимание, что я не могу этого сделать с хранением.

Некоторые полезные ссылки:

В дополнение к предыдущим ответам есть одно важное для меня замечание:

При использовании JetBrains IDE с Git, «операции по хранению и извлечению из хранилища поддерживаются в дополнение к размещению и снятию с полки. У этих функций много общего; основное различие заключается в способе создания и применения исправлений. Shelve может работать как с отдельными файлами, так и с группами файлов, в то время как Stash может работать только с целым набором измененных файлов одновременно. Вот несколько подробнее о различиях между ними «.

Источник

Shelve and unshelve changes

Shelving is temporarily storing pending changes you have not committed yet. This is useful, for example, if you need to switch to another task, and you want to set your changes aside to work on them later.

You cannot shelve unversioned files, which are files that have not been added to version control.

Once shelved, a change can be applied as many times as you need.

Shelve changes

In the Shelve Changes dialog, review the list of modified files.

In the Commit Message field, enter the name of the shelf to be created and click the Shelve Changes button.

If you need to copy your changes to a shelf without resetting local changes, press Ctrl+Shift+A and look for the Save to Shelf action.

Unshelve changes

Unshelving is moving postponed changes from a shelf to a pending changelist. Unshelved changes can be filtered out from view or removed from the shelf.

In the Shelf tab, select the changelist or the files you want to unshelve.

Press Ctrl+Shift+U or choose Unshelve from the context menu of the selection.

In the Unshelve Changes dialog, specify the changelist you want to restore the unshelved changes to in the Name field. You can select an existing changelist from the list or enter the name for a new changelist to be created containing the unshelved changes. You can enter the description of the new changelist in the Comment field (optional).

If you want IntelliJ IDEA to preserve the context of a task associated with the new changelist on its deactivation and restore the context when the changelist becomes active, select the Track context option (see tasks and contexts for details).

If you’ve deleted unshelved files by accident, you can view and restore them from the Recently Deleted node.

You can also drag a file or a changelist from the Shelf tab to the Local Changes view to unshelve it silently. If you drag it holding the Ctrl key, it will be copied to the Local Changes tab instead of being removed from the shelf.

Discard shelved changes

In the Shelf view, select the changelist that contains the changes you do not want to keep any more.

Restore unshelved changes

Select the files or the shelf you want to restore.

From the context menu of the selection, choose Restore.

Apply external patches

You can import patches created inside or outside IntelliJ IDEA and apply them as shelved changes.

In the Shelf view, choose Import Patches from the context menu.

In the dialog that opens, select the patch file to apply. The selected patch appears in the Shelf tab as a shelf.

Select the newly added shelf with the patch and choose Unshelve Changes from the context menu of the selection.

Automatically shelve base revision

It may be useful to configure IntelliJ IDEA to always shelve base revisions of files that are under Git version control.

Select the Shelve base revisions of files under distributed version control systems option.

If this option is enabled, the base revision of files will be saved to a shelf that will be used during a 3-way merge if applying a shelf leads to conflicts. If it is disabled, IntelliJ IDEA will look for the base revision in the project history, which may take a while; moreover, the revision that the conflicting shelf was based on may be missing (for example, if the history was changed as a result of the rebase operation).

Change the default shelf location

By default, the shelf directory is located under your project directory. However, you may want to change the default shelf location. This can be useful, for example, if you want to avoid deleting shelves accidentally when cleaning up your working copy, or if you want to store them in a separate repository allowing shelves to be shared among your team members.

Click Change Shelves Location and specify the new location in the dialog that opens.

If necessary, select Move shelves to the new location to move existing shelves to the new directory.

Watch this video tutorial on how to benefit from shelves to be able to switch to a different task without losing unfinished work:

Источник

Фишки IDEA. Часть 2

Продолжаем разговор о фишках IDEA по мотивам внутренних митапов Максилекта. В прошлый раз обсудили интерфейс, а сегодня речь пойдет об удобных средствах отладки и инструментах совместной работы с кодом.

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

Scratch-файлы

Shelve

IDEA Shelve по аналогии с git stash позволяет не смешивать контексты при переключении с одной задачи на другую.

Кстати, IDEA многое отправляет в shelve автоматически.

Если собственный механизм IDEA почему-то не нравится, можно переключиться на git stash.

Закачка на удаленный хост

Следующая рекомендация для тех, кто любит все выполнять только в IDEA.

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

Инструмент позволяет даже создавать файлы на сервере.

Интеграция с Docker

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

У IDEA есть интерфейс для работы с docker’ом. Здесь можно запускать контейнеры, просматривать логи, подключаться к контейнеру через терминал, расшаривать порты и т.д.

Changelist

Изменения можно перетаскивать из одного changelist-а в другой. Также changelist-ы можно разбивать или объединять.

Подробное описание работы с Changelist есть в документации.

Дерево коммитов

Это удобный инструмент, позволяющий вносить изменения в различные ветки проекта. Здесь отлично видно, кто что сделал, что с чем и куда было смержено.

В дереве коммитов есть поиск по commit message, имени задачи и хэшу коммита.

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

Дерево коммитов показывает несколько проектов, если ранее вы подключили их в одно окно. Чтобы не запутаться, можно показать дерево только для одного репозитория (для этого в Paths надо выбрать, какой репозиторий сейчас актуален).

Дерево открывает широкие возможности для манипулирования коммитами. В частности, оно позволяет:

откатывать коммит (Undo commit), после чего он попадает обратно в Change list;

перетаскивать ветку с одного коммита на другой;

сравнивать два разных коммита между собой.

Breakpoints

В процессе отладки IDEA позволяет устанавливать Breakpoint-ы. В этот момент можно, например, выводить информацию в лог.

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

В настройках можно также указать, что точка остановка должна сработать только один раз. Или она должна быть неактивна, пока мы не достигли определенной точки (Disable until hitting the following breakpoint).

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

А если поджимает время выполнения запроса, можно выбрать Evaluate and log. Выполнение не остановится, но данные будут выводиться в консоль.

Останавливаясь на breakpoint, можно воспользоваться кнопкой Evaluate Expression (горячая клавиша Alt + Shift + 8). Она открывает окно, в котором можно исполнять код прямо в рантайме в точке остановки, где будут доступны все зарезервированные объекты. Так можно модифицировать запросы из кода, проверяя быстрые гипотезы.

Тестирование в IDEA

У тестирования непосредственно через IDEA есть одно важное преимущество. Если запускать тесты сторонним инструментом, в консоли появится индекс запускаемого теста. Если же тесты запускать через IDEA, она выведет названия тестов.

Профайлер IDEA

В IDEA предусмотрена интеграция с инструментами для профилирования. Из коробки доступны Async Profiler и Java Flight Recorder. Выбрать, какой будет использоваться в данный момент, можно через Preferences в секции Profiler.

Shelve changes git что это. image loader. Shelve changes git что это фото. Shelve changes git что это-image loader. картинка Shelve changes git что это. картинка image loader

Преимущество использования профайлера непосредственно из под IDEA в том, что при изучении результатов можно перемещаться не только по этой картинке, но и по исходному коду.

Кстати, у некоторых коммерческих профайлеров тоже есть интеграция с IDEA. Если установить соответствующие плагины, их можно будет выбрать из списка в Preferences.

Анализ stack trace

Лайфхак для код-ревью

В ходе обсуждения возможностей IDEA всплыл интересный лайфхак, который помогает лучше ориентироваться в чужом коде во время ревью. Это не отдельный инструмент, но все же мы решили его здесь упомянуть.

Если изменений в коде много, для ревью удобно вытянуть всю ветку к себе, откатить все коммиты этого реквеста (Reset soft) до того, как он был влит в мастер, и выполнить git reset master. Все изменения в этом реквесте останутся в рабочей копии и будут отображаться, как будто они внесены собственными силами. Изменения попадут индекс Git и будут там подсвечиваться (сами они при этом не изменяются). Можно будет перемещаться по зависимостям.

В отличие от Git-> Compare with branch, который просто показывает список изменения, здесь будет более удобная навигация. Правда, можно случайно что-то поправить в коде, и новые изменения не будут выделяться на фоне остальных.

Безусловно, функционал IDEA намного шире. Но мы надеемся, что наша выжимка опыта будет вам полезна.

Статья написана по материалам внутренних митапов Максилект.

Источник

Shelve and unshelve changes

Shelving is temporarily storing pending changes you have not committed yet. This is useful, for example, if you need to switch to another task, and you want to set your changes aside to work on them later.

You cannot shelve unversioned files, which are files that have not been added to version control.

Once shelved, a change can be applied as many times as you need.

Shelve changes

In the Shelve Changes dialog, review the list of modified files.

In the Commit Message field, enter the name of the shelf to be created and click the Shelve Changes button.

If you need to copy your changes to a shelf without resetting local changes, press Ctrl+Shift+A and look for the Save to Shelf action.

Unshelve changes

Unshelving is moving postponed changes from a shelf to a pending changelist. Unshelved changes can be filtered out from view or removed from the shelf.

In the Shelf tab, select the changelist or the files you want to unshelve.

Press Ctrl+Shift+U or choose Unshelve from the context menu of the selection.

In the Unshelve Changes dialog, specify the changelist you want to restore the unshelved changes to in the Name field. You can select an existing changelist from the list or enter the name for a new changelist to be created containing the unshelved changes. You can enter the description of the new changelist in the Comment field (optional).

If you want CLion to preserve the context of a task associated with the new changelist on its deactivation and restore the context when the changelist becomes active, select the Track context option (see tasks and contexts for details).

If you’ve deleted unshelved files by accident, you can view and restore them from the Recently Deleted node.

You can also drag a file or a changelist from the Shelf tab to the Local Changes view to unshelve it silently. If you drag it holding the Ctrl key, it will be copied to the Local Changes tab instead of being removed from the shelf.

Discard shelved changes

In the Shelf view, select the changelist that contains the changes you do not want to keep any more.

Restore unshelved changes

Select the files or the shelf you want to restore.

From the context menu of the selection, choose Restore.

Apply external patches

You can import patches created inside or outside CLion and apply them as shelved changes.

In the Shelf view, choose Import Patches from the context menu.

In the dialog that opens, select the patch file to apply. The selected patch appears in the Shelf tab as a shelf.

Select the newly added shelf with the patch and choose Unshelve Changes from the context menu of the selection.

Automatically shelve base revision

It may be useful to configure CLion to always shelve base revisions of files that are under Git version control.

Select the Shelve base revisions of files under distributed version control systems option.

If this option is enabled, the base revision of files will be saved to a shelf that will be used during a 3-way merge if applying a shelf leads to conflicts. If it is disabled, CLion will look for the base revision in the project history, which may take a while; moreover, the revision that the conflicting shelf was based on may be missing (for example, if the history was changed as a result of the rebase operation).

Change the default shelf location

By default, the shelf directory is located under your project directory. However, you may want to change the default shelf location. This can be useful, for example, if you want to avoid deleting shelves accidentally when cleaning up your working copy, or if you want to store them in a separate repository allowing shelves to be shared among your team members.

Click Change Shelves Location and specify the new location in the dialog that opens.

If necessary, select Move shelves to the new location to move existing shelves to the new directory.

Watch this video tutorial on how to benefit from shelves to be able to switch to a different task without losing unfinished work:

Источник

Git Stash vs Shelve in IntelliJ IDEA

I am very unfamiliar with the shelve aspect of Git. If stash is used to put aside unfinished work what is shelve then? What would you use it for?

For example on Update Project (from VCS menu)

Shelve changes git что это. u0UO4. Shelve changes git что это фото. Shelve changes git что это-u0UO4. картинка Shelve changes git что это. картинка u0UO4

one will get (in IntelliJ IDEA 2019.2)

Shelve changes git что это. US0hp. Shelve changes git что это фото. Shelve changes git что это-US0hp. картинка Shelve changes git что это. картинка US0hp

Shelve changes git что это. iZiGj. Shelve changes git что это фото. Shelve changes git что это-iZiGj. картинка Shelve changes git что это. картинка iZiGj

5 Answers 5

git shelve doesn’t exist in Git.

You had a 2008 old project git shelve to isolate modifications in a branch, but that wouldn’t be very useful nowadays.

As documented in Intellij IDEA shelve dialog, the feature «shelving and unshelving» is not linked to a VCS (Version Control System tool) but to the IDE itself, to temporarily storing pending changes you have not committed yet in changelist.

Shelve changes git что это. I4fiW. Shelve changes git что это фото. Shelve changes git что это-I4fiW. картинка Shelve changes git что это. картинка I4fiW

When using JetBrains IDE’s with Git, «stashing and unstashing actions are supported in addition to shelving and unshelving. These features have much in common; the major difference is in the way patches are generated and applied. Shelve can operate with either individual files or bunch of files, while Stash can only operate with a whole bunch of changed files at once. Here are some more details on the differences between them.»

Shelve changes git что это. 3nqhu. Shelve changes git что это фото. Shelve changes git что это-3nqhu. картинка Shelve changes git что это. картинка 3nqhu

In addition to previous answers there is one important for me note:

Shelve changes git что это. mLIJK. Shelve changes git что это фото. Shelve changes git что это-mLIJK. картинка Shelve changes git что это. картинка mLIJK

I would prefer to shelve changes instead of stashing them if I am not sharing my changes elsewhere.

Stashing is a git feature and doesn’t give you the option to select specific files or changes inside a file. Shelving can do that but this is an IDE-specific feature, not a git feature:

Shelve changes git что это. bwKYZ. Shelve changes git что это фото. Shelve changes git что это-bwKYZ. картинка Shelve changes git что это. картинка bwKYZ

As you can see I am able to choose to specify which files/lines to include on my shelve. Note that I can’t do that with stashing.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *