Showing posts with label git-ignore. Show all posts
Showing posts with label git-ignore. Show all posts

How can I Remove .DS_Store files from a Git repository?

 Remove existing .DS_Store files from the repository:

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

Add this line:

.DS_Store

to the file .gitignore, which can be found at the top level of your repository (or create the file if it isn't there already). You can do this easily with this command in the top directory:

echo .DS_Store >> .gitignore

Then commit the file to the repo:

git add .gitignore
git commit -m '.DS_Store banished!'

Ignore Files or Folders from Git - Git Ignore or Exclude

In your projects .git\info directory there is an exclude file that is effectively the same thing as .gitignore (I think). You can add files and directories to ignore in that.

Suppose, I want exclude target/classes folder from my project abc.

File Structure :

abc
|
|
target     src     resources   .git
|                                          |
|                                          |
classes   repo   lib              info
                                           |
                                           |
                                           exclude (file)

Now, inside abc there is a .git folder and inside of that there is info folder. Inside the info folder, there is exclude file.

Open it and add the following to ignore target/classes folder from above example.

$: vi exclude

/target/classess

Done. Similarly add the folder as per your project structure to exclude or ignore it from git.