DEV Community

Cover image for A Quick Way To Locally Ignore Files From Git.
Emmanuel Hayford
Emmanuel Hayford

Posted on • Edited on

1

A Quick Way To Locally Ignore Files From Git.

Often times, I've found myself having to git ignore some files that I shouldn't be pushing to a repository on GitHub, so I'd do something like git add file.rb another_file.rb selectively just so I can commit only the files that I want to make changes to. This is tedious, not to mention a huge waste of time.

If you're familiar with Rails, sometimes you'll need to make a change to your database.yml or even to your Gemfile. Changes you make to these files are only specific to you and you don't need to push this for everyone else, neither do you want to edit .gitignore.

Here's an easy way to locally ignore your changes so you don't have to keep tracking them mistakenly or spend time to selectively track some files.

I added these commands to my aliases so they're easy to access:

alias untrack='git update-index --assume-unchanged'

You can use this like so: untrack database.yml

To undo this you'd do track database.yml but only if you've added track='git update-index --no-assume-unchanged' and of course untrack and track can be anything you choose.

Happy coding!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay