Перейти к содержимому
shvechikov.net

Поиск по сайту

Введите запрос, чтобы найти статьи и проекты.

How to ignore files that have already been committed to a Git repository

1 мин чтения

Hi! Do you often come across a situation when your .gitignore file needs to be improved? This is a very common situation when you need to stop committing some files and directories to your repository.

First of all, you should run this command:

git rm -r --cached .

This command will remove all modified files from indexing. Then you need to re-add them, using the command below:

git add .

Re-commit the changes (I'm sure you've already made the changes to your .gitignore):

git commit -m "Update .gitignore"

That's all! Now you can safely execute your push request. Files that were added to .gitignore will be removed from the repository.

Good coding!