HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-02-26
1 <p>Давайте, рассмотрим три ситуации. Первая. Вы добавили файлы/директории в репозиторий, но не добавили их еще в индекс (git add) и поняли что они не нужны. В таком случаем можно обойтись git clean</p>
1 <p>Давайте, рассмотрим три ситуации. Первая. Вы добавили файлы/директории в репозиторий, но не добавили их еще в индекс (git add) и поняли что они не нужны. В таком случаем можно обойтись git clean</p>
2 mkdir one touch two git status On branch main Your branch is up to date with 'origin/main'. # Пустые директории в git не добавляются в принципе. # Физически директория one находится в рабочей директории, # но её нет в git, и он её игнорирует Untracked files: (use "git add &lt;file&gt;..." to include in what will be committed) two # Выполняем очистку # -f - force, -d - directory git clean -fd Removing one/ Removing two<p>Вторая ситуация - нужно отменить изменения в новых файлах, но не удалять их. Тут вам поможет git restore</p>
2 mkdir one touch two git status On branch main Your branch is up to date with 'origin/main'. # Пустые директории в git не добавляются в принципе. # Физически директория one находится в рабочей директории, # но её нет в git, и он её игнорирует Untracked files: (use "git add &lt;file&gt;..." to include in what will be committed) two # Выполняем очистку # -f - force, -d - directory git clean -fd Removing one/ Removing two<p>Вторая ситуация - нужно отменить изменения в новых файлах, но не удалять их. Тут вам поможет git restore</p>
3 echo 'new text' &gt; INFO.md git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add &lt;file&gt;..." to update what will be committed) (use "git restore &lt;file&gt;..." to discard changes in working directory) modified: INFO.md git restore INFO.md<p>И наконец, новые файлы добавлены в индекс. Здесь также не обойтись без git restore</p>
3 echo 'new text' &gt; INFO.md git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add &lt;file&gt;..." to update what will be committed) (use "git restore &lt;file&gt;..." to discard changes in working directory) modified: INFO.md git restore INFO.md<p>И наконец, новые файлы добавлены в индекс. Здесь также не обойтись без git restore</p>
4 echo 'new text' &gt; INFO.md git add INFO.md git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged &lt;file&gt;..." to unstage) modified: INFO.md git restore --staged INFO.md git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add &lt;file&gt;..." to update what will be committed) (use "git restore &lt;file&gt;..." to discard changes in working directory) modified: INFO.md
4 echo 'new text' &gt; INFO.md git add INFO.md git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged &lt;file&gt;..." to unstage) modified: INFO.md git restore --staged INFO.md git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add &lt;file&gt;..." to update what will be committed) (use "git restore &lt;file&gt;..." to discard changes in working directory) modified: INFO.md