tags:

views:

36

answers:

3

Hi All,

I have a git repository hosted on a server. We are 5 members in the team and all have cloned from this same repo. Since the start .log and .yml files are being tracked.

Is there a simple way to make Git not to track these files. We have tried --assume-unchanged but we were not able to get through.

Could anyone suggest step by step instructions to achieve above?

Thanks, Imran

A: 

Create a file called .gitignore and add filenames that need to be ignored to it.

Check out the "Ignoring Files" section.

advait
I do not believe that you can .gitignore files that are already in the repository. As Imran mentioned above, you will also have to "git rm" them and commit the change.
TheJacobTaylor
+3  A: 

You can create a file called ".gitignore" in the root of the repository with the following contents:

*.yml
*.log

To make git ignore changes to files matching the pattern. To remove your already existing copies of .yml files and .log files, you'd do this:

rm *.yml *.log
git rm *.yml *.log
git commit -m "removed .yml and .log files"

If you don't want to remove the .yml files (assuming they are configuration files of sort), you can add them to .gitignore, but still git-add a default one for the repository. If anyone were to change their .yml files, git would ignore the changes.

If you want everyone to have the same .gitignore file, add it to the repo as well. If you want everyone to be able to freely configure their .gitignore file for their own purposes, you can add ".gitignore" to the .gitignore file.

A: 

TheJacobTaylor, yes you are right. They are already being tracked and they are in .gitigonre as well. However, I added them in .gitignore after they were being tracked, and I understand they won't be ignored this way.

Supposing, we are two members on team and I do the following on my cloned copy:

rm *.yml *.log 
git rm *.yml *.log 
git commit -m "removed .yml and .log files" 

What the other member need to have the same effect? Repeat the same above or just pull the code, considering we need to have the same .gitignore files. – Imran

Imran
When they pull that commit, the removed files will be removed for them too. If you also want them to ignore any .yml or .log files added later, you must add the .gitignore file to the repo as well.
Thanks ja-cop and TheJacobTaylor, I really appreciate your help, and it was quick too :) .
Imran