.gitignore in subdirectory is getting ignored - gitignore

I have created a .gitignore file in a subdirectory.
/errors/company/.gitignore
I need it to ignore the file /errors/company/seiten/start/content.phtml.
Content of .gitignore:
seiten/start/content.phtml
But it does still show the file if execute git status. Why?

If you have already commited the .gitignore file, and you still see that file in git status, it is because the file was being tracked from before. You should do the following:
git rm --cached /errors/company/seiten/start/content.phtml
That should do the trick.
PD: I would leave just one .gitignore in the root directory with all the ignored paths and files.

Related

Why doesn't this ignore my files recursively?

In my project's root directory there are directories like 'tools':
tools/evaluate/test/
tools/evaluate2
Under test, there are some .py and .csv files. I want to ignore all files except .py, so in my .gitignore, I have this entry:
!tools/**/*.py
I want to recursively ignore all non-python files under tools. What's wrong with that?
if the files you are trying to ignore have been already committed, you need to remove them from the staging area as well, that's done by:
git rm --cached !tools/**/*.py
check the status:
git status
add the files you want to delete to .gitignore i assume manually, i don't know of an automatic way, then finally:
git add .gitignore
git commit -m "Remove unused files"
Two parts are needed here:
# Recursively ignore everything in tools that has an extension:
**/tools/**/*.*
# Except .py files recursively in tools:
!tools/**/*.py

How can I stop cloning my application files on GitHub?

I want to stop cloning my application files to Github, How can I do that completely and remove the circle status on each solution files?
Environment: Visual Studio for Mac
Are you intending to have git ignore those files completely?
You can use a gitignore file (.gitignore) in the root working directory of your project to specify which files to ignore. In there, specify a filename per line in that file, or a whole directory to be ignored (eg: Shared/*).
You'll also need to remove those files from your git repo, since they've already been committed.
Copy-pasting from here:
Unstage the file
git reset HEAD newfile
Remove the file from git
git rm --cached newfile
Deleting the file will count as a commit, so you'll need to git push once you're done.
Also note that the file(s) and their contents will still exist in the git commit history, so this isn't a good idea if the goal is removing files with sensitive info.

How can I ignore any changes in a particular folder from Git

I want to exclude the changes in all files in a folder Api\Bin*.* and Core\obj*.* into GitHub merging. I dont want to consider that folder while merging the changes. How can I do that Please advise. I have added the following line of code in ignored file from Repository->Setting->Ignored files , but not working . When compile the program , still obj and bin folder files is showed in changes of GitHub
You can add a line in gitingore files following ways
logs/
These lines will ignore the logs folder. Even you can use patterns.
If those files are already tracked, no amount of .gitignore would work.
You need to remove them first (from the Git index, not from your disk)
git rm --cached -r API/bin/
git rm --cached -r Core/obj/
Then check (no commit needed) if you see them in GitHub Desktop.
You can also see if your .gitignore rules apply with:
git check-ignore -v -- Core/obj/<anObjFile>

gitignore > some ignored files still added to the repository

I don't understand why ignored files are still added to the repository. Are there some circumstances when files which are in the .gitignore list, can be still added to the repository
I added directory to the .gitignore before I did anything with the project (project is clean, no trucked or untracked files). Then I built the project. During the build process some files were modified. When the build was done, most of the modified files were ignored, but some were added to the repository. I don't understand this git's selectivity.
Usually, files are added to the index when modified if they were tracked before the .gitignore referenced them.
Try:
git rm --cached -r biz/modules/rest-apis/docs/refAddress
Then control that all files are ignored, by selecting one which was added before:
git check-ignore -v -- biz/modules/rest-apis/docs/refAddress/GET_1.0_v4_addresses.json
You should see a .gitignore rule (no output means: the file is not ignored).

Ignoring .DS_Store in a gitignore file using Tower

I have a new repo and before I perform the first commit I'd like to ignore .DS_Store files.
I've tried adding the following to the .gitignore file via Tower:
.DS_Store
*.DS_Store
*/.DS_Store
But only the .DS_Store file at the root is ignored, all others are included ready for commit.
Is there a trick to getting these files to be ignored?
**/.DS_Store
try it out :) Hope it help
Make sure you didn't add to the index those DS_Store first.
If you did, check out "How Can I Remove .DS_Store Files From A Git Repository?", and then check if your .gitignore works.
Use git rm --cached if you want just to remove then from the index while keeping them in the working tree.
Note: only .DS_Store should be enough in your case.
See Objective-C.gitignore from the GitHub Collection of Useful .gitignore Templates.