Excluding a folder in .gitignore - github

I am trying to exclude a folder in my project and have added the following lines to the .gitignore:
logs/
tempStorage/
libraries/lib/
The first two are excluded but the last one is still being updated. That folder contains DLLs that are generated by another project in the solution.
I am using Visual Studio 2022. When I rebuild the solution the project target lib updates the DLLs. I don't want to store these in git.
Do I need to do something in git like delete the files?

Related

.gitignore not ignoring a folder within a directory

It seems a straightforward one, but having researched multiple ways to do it, I can't gitignore a folder within a directory.
I have a root directory which contains all of my code in it. Because it has some back-end NodeJS stuff in it, it has a 'node_modules' folder which contains hundreds of files. As a result, when I try to upload the entire parent folder, GitHub says there's too many files to upload and tells me to reduce the number I'm uploading.
The crucial part is though, the folder has to be uploaded as a whole, as it itself is within a GitHub repository with other files with different folders in.
That means when I go onto my repository, I need this folder's files to display within the folder, and not separately within the repository. I need all of the files to be within this folder, within the parent repository, excluding the node_modules folder.
For example ->
Parent repository -> Child Directory (what I'm uploading) -> Individual files
I've tried to add the node_modules folder to my gitignore through the following methods:
Adding: node_modules/ to my gitignore file
Writing: echo node_modules >> .gitignore through my terminal
Adding a separate gitignore file within my node_modules file with a * in it
None of them have worked and I can't find any other solutions. For reference I'm using a Mac.
Does anyone have any idea what I'm doing wrong, or how it'd be best to do it?
By default, you do not need to include the node_modules folder in your repositories because the package.json file contains all of your project's dependency information. This means that anyone who clones your repository can run npm install and have the entire node_modules folder without problems.
To solve this you can create your own .gitignore file, creating a new file at the root of your project and renaming it to .gitignore (writing exactly that way). Then you can open it with any text editor and add */node_modules to one of the lines.
This will likely solve your problem.

ignoring the build folder in an eclipse project in git repo

I am using eclipse java as an editor and would like to use the .gitignore to exclude the build folder for the project. This is what I have currently written in my .gitignore. The syntax seems to be right; I used the git documentation but I may have interpreted it wrong.
#ignoring the files within the build folder
/build/
build/**
I'm using a brand new repo so I shouldn't have any problems with already logged files in the repo.
I am trying to get git to ignore the build folder in the project file using a .gitignore. The ignore file didn't work. What could be a solution?
The way the .gitignore is written, this file needs to be in the same subfolder as the build folder, the file being ignored.

How do I remove Mercurial .HG folder from project but still keep it under source control?

I am using Visual Studio 2010 and
I noticed when I published my project that all the files in the published directory were also under source control which I don't want. When I looked at one of my other projects under source control I noticed it didn't have the .hg folder and publishes without issue. I then removed the .hg folder and I was able to build and publish and the files were no longer under source control BUT now my project isn't either.
I put back the .hg folder and I'm back where I started. How do I remove the .hg folder from my project but still retain source control?
The .hg directory cannot be removed. It contains everything Mercurial knows about your project. Deleting that directory effectively removes all source control.
Add files you don't want to be tracked to the .hgignore file in the root of your repository instead. See the hgignore documentation for the format of this file.

Nuget: How to copy a files to root folder without including in project

If you put any files in the Content folder of a Nuget package, during installation these files are:
Copied to the root of the target project and
Included in the project.
Is there any way to make Nuget skip action 2, i.e. to copy them but not include them in the project?
I know I can do this with a Powershell script that goes in and removes the files from the project. But I don't think that's a very robust method.
Can I achieve this without relying on Powershell?
You can try adding your contents directly in the package instead of the "contents" folder.
Files outside "contents" would be ignored by NuGet while trying to add content files.
Then you can do just the copying part using your powershell scr

Eclipse deleting project but not the source code

Is there a way to delete an Eclipse project while preserving all the resources? (i.e. source code, etc.).
I guess I could delete the following files from the project directory manually:
.cproject
.project
But I am concerned that my Eclipse .metadata information that lives in my workspace may still look for those files and get confused if I delete the project files manually.
What I usually do is remove the project using eclipse (do not delete project contents on disk) and remove any .* eclipse-related file that could stay.
With the checkout unchecked, it deletes the project informations while preserving the source code.