1

I'm having trouble understanding exactly how the .gitignore file works.

Say I have the following .gitignore:

/db/*.sqlite3
/log/*.log
/public/uploads/*

On all of my computers, I have a file /db/development.sqlite3

My questions are:

  1. If the file is already in the repository, will it pull down the version in the repo every time I git pull?

  2. Do files in the gitignore file need to be untracked on all systems in order to not pull or push to or from the repo?

  3. If I decide to add another line /tmp/** /* to my gitignore after the fact, do I need to go into each workstation/live server to untrack the files? And do I need to push a version to the repo that has /tmp/** deleted?**

sabrams
  • 1,128
  • 2
  • 15
  • 28

1 Answers1

1

If the file is already in the repository, will it pull down the version in the repo every time I git pull?

Do files in the gitignore file need to be untracked on all systems in order to not pull or push to or from the repo?

  • This shouldn't be needed as long as you download the changes and merge it in your current branch. If you don't do that you could face some errors

If I decide to add another line /tmp/** /* to my gitignore after the fact, do I need to go into each workstation/live server to untrack the files? And do I need to push a version to the repo that has /tmp/** deleted?**

  • The first part is answered above. You will need to push that version with this new path deleted
Community
  • 1
  • 1
iberbeu
  • 15,295
  • 5
  • 27
  • 48
  • So basically, for any file or directory that I want ignored, if it is already commited, or in the repo, I just need to run `git rm` on that file or directory? – sabrams Oct 27 '14 at 16:49
  • yes. That should work. I had this situation a couple of times and it is always a mess. You have to be careful and check that a branch is not overriding what the other task did so at the end the file is not ignored... But after a couple of tries you will get it work. Or may be in the first try, who knows... – iberbeu Oct 27 '14 at 16:54