Skip to content

Instantly share code, notes, and snippets.

@thiagobraga
Last active January 6, 2021 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagobraga/d10feada3d42c95466d97560b3c94974 to your computer and use it in GitHub Desktop.
Save thiagobraga/d10feada3d42c95466d97560b3c94974 to your computer and use it in GitHub Desktop.
[Git] Como ignorar arquivos localmente sem incluir no .gitignore

Ignorar alterações em arquivos com update-index

git update-index --assume-unchanged package.json
git update-index --assume-unchanged resources/assets/sass/old_css/helper.css
git update-index --assume-unchanged resources/views/errors/500.blade.php
git update-index --assume-unchanged resources/views/layouts/admin/head.blade.php
git update-index --assume-unchanged resources/views/layouts/admin/master.blade.php
git update-index --assume-unchanged resources/views/layouts/student/head.blade.php
git update-index --assume-unchanged resources/views/layouts/student/master.blade.php
git update-index --assume-unchanged webpack.js.mix.js

Não ignorar alterações

git update-index --no-assume-unchanged package.json
git update-index --no-assume-unchanged resources/assets/sass/old_css/helper.css
git update-index --no-assume-unchanged resources/views/errors/500.blade.php
git update-index --no-assume-unchanged resources/views/layouts/admin/head.blade.php
git update-index --no-assume-unchanged resources/views/layouts/admin/master.blade.php
git update-index --no-assume-unchanged resources/views/layouts/student/head.blade.php
git update-index --no-assume-unchanged resources/views/layouts/student/master.blade.php
git update-index --no-assume-unchanged webpack.js.mix.js

Incluir no .git/info/exclude

Este caso é para arquivos untracked pelo git. Como não é possível utilizar o update-index para um arquivo que ainda não foi versionado, podemos usar o arquivo exclude do git.

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
docker-compose.override.yml
docker/php/xdebug.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment