.gitignore_global has no effect on .idea/ created by JetBrains - gitignore

I am trying to get Git to ignore .idea/ created by JetBrains' product but somehow it works on every folder I created except the .idea/ created by JetBrains. Why ?
So how do I globally ignore .idea/ ?
I already had my core.excludesfile set to ~/.gitignore_global

Make sure first that folder was not already tracked:
cd /path/to/repo
git rm -r --cached .idea/
Then check your git status: add, commit (register the deletion): the .gitignore should now be in effect for that folder.
To check that the folder ignore rule is in effect:
git check-ignore -v -- .idea/a_file_inside_.idea_folder
As long as it returns nothing, that file (inside the .idea folder) is not ignored.
That git check-ignore command will consider all ignore files possible, including the core.excludesfile one (in your case set to ~/.gitignore_global)

Related

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).

Git ignore not ignoring directories

I'm trying to ignore obj, bin, debug type files/directories from my Visual studio project. I've followed the advice here:
ignoring any 'bin' directory on a git project
This is not working.
I've pasted the entire git ignore here:
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
This is not working.
I've tried all sorts of things...
bin/
obj/
*bin/
*obj/
/bin/
/obj/
packages
MyProject/MyProject/obj/
MyProject/MyProject/bin/Debug/
MyProject/MyProject/obj/*
MyProject/MyProject/bin/Debug/*
The directories and their files are still being included when I run a git add. The .gitignore file is added and commited. What am I doing wrong???
EDIT: The files I'm trying to ignore aren't already being tracked. When I run a "git status" there are no pending changes. "nothing to commit, working tree clean". Then I run my VS program which modifies the files in those folders. Then I run another git status and all of the files show up as "modified"...
EDIT2: Does it matter if the files already exist? They are not being tracked but DO exist in the folder structure. When when I run the program they show up again as "modified". Then I have to run a "git checkout ." to remove them all. Then the cycle repeats...
If your file was already been tracked and committed before adding in .gitignore, it won't ignore it. You would require to remove it from index to stop tracking
For file
git rm --cached <file need to remove>
For Folders
git rm -r --cached <folder>
So that would be an issue in your case since Jenkins is still able to see the file in the repo
Hi look at the edit part ,
If you already have any folders in your git index which you no longer wish to track then you need to remove them explicitly. Git won't stop tracking paths that are already being tracked just because they now match a new .gitignore pattern. Execute a folder remove (rm) from index only (--cached) recursivelly (-r).
git rm -r --cached yourfolder
Based on your "Edit 2" above, it sounds like you don't think these have been previously committed, but in reality, they have been. If it shows up as "modified", the git is recognizing the file has changed from the last version it has checked in. If the file was not already committed previously then it would show up as Untracked.
When you are running git checkout on those files, you are telling git to revert those files back to the last version that was checked into git.

.gitignore in subdirectory is getting ignored

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.

restore.dg is not fitlered by .gitignore

In my newest .NET Core ASP.MVC project I seem to be unable to ignore the restore.dg file. By default, the Visual Studio .gitignore file is set to ignore the whole .vs/ folder, in which the file is located. As this did not work, I tried several methods how to get rid of the file, yet unsuccessfully.
# Visual Studio 2015 cache/options directory
.vs/
restore.dg
*.dg
.vs/*
Could somebody help me?
Remove it from the cache.
git rm --cached .vs/restore.dg
git commit -m "Remove restore.dg from the cache"
See also: How to make Git "forget" about a file that was tracked but is now in .gitignore?
This might happen after you have already committed this file into the repository. If this is the case you have to remove it using git rm --cached <filename> command and commit this change to the repository. After that it will disappear from git status and will never bother you again.