5

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

Saim
  • 2,471
  • 5
  • 30
  • 43
  • Not really sure what you mean - can't you just do: git rm *.log *.yml Then add them to .gitignore? What exactly do you mean by 'not to track'? – jA_cOp Jul 20 '10 at 05:34
  • Thanks for the quick reply. Well, do I need to do: git rm *.log *.yml on all cloned copies, or just from one and push the code and other members pull the code? If I do this, then for every new cloned copy, I need to manually create a .yml file? – Saim Jul 20 '10 at 05:38
  • If the .yml file should be in the repo, why do you want to remove it? What am I missing here? Is it so that you want an initial .yml file on the remote repo, but you want everyone to be able to freely configure their own copies? – jA_cOp Jul 20 '10 at 05:42
  • i was looking for something like : https://stackoverflow.com/questions/2006172/how-to-reset-a-remote-git-repository-to-remove-all-commits#2006252 – jmunsch Jan 23 '18 at 18:27

2 Answers2

7

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.

jA_cOp
  • 3,275
  • 19
  • 15
0

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

Check out the "Ignoring Files" section.

advait
  • 6,355
  • 4
  • 29
  • 39
  • 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 Jul 20 '10 at 05:47