Does sourcetree automatically load .gitignore file? - gitignore

I create .gitignore file by textedit on mac.
( by following Adam of link Git ignore file for Xcode projects I create empty txt format file, and copy and paste it.)
And I put that file in .git folder in the project folder.
Then, Does sourcetree will 'automatically' load this .gitignore file as soon as I put the file in that folder ?

Put it directly in the project folder not to .git. It will be automatically loaded by sourcetree from that folder

Related

When I push a cpp file to the github repository then an exe file gets added. What can I do so that I don't get those exe files

Whenever I push a cpp file to my github repository an exe file gets added to the repository. I don't want that exe file.How to do that?
you want the file not be tracked across everyone's repositories create a pattern as below in .gitignore file. This file can either be in root directory of you application or a the directory you .cpp and .exe files are in.
*.exe
If you want .exe files to be ignored for only you. Then you can put above pattern in .git/info/exclude
Follow this link for more info:
https://www.atlassian.com/git/tutorials/saving-changes/gitignore

How to recover files from .gitignore

while uploading files to the repository in GitHub, I accidentally click to the button to ignore the files from the upload. Now these files are in a folder called '.gitignore'.
How can I recover these files?
I'm able to see and modify them, I just want to know how to upload them in the repository.
Thanks in advance
I think you misunderstand the concept of .gitignore "folder".
It is instead a text file, with the path of the ignored directories or files.
Consider the following .gitignore file.
foo/bar.txt
foobar/
This will tell git to ignore the directory foobar as well as the file foo/bar.txt, and therefore you won't be able add the files to a commit or push it to a remote repository.
But you can simply remove a file from the list of ignored files and directories by opening the .gitignore file, deleting the line with the corresponding file and saving the .gitignore file. You then should the be able to add the file to a commit and push it to a remote repository.
More information about .gitignore can be found here

.gitignore file not ignoring .env.local or any other supposed private file

I encountered this error because I once mistakenly committed .env.local before adding it to .gitignore. The answer to it below.
If you're facing something similar and you use the Git GUI in VSCode, just follow these steps:
Open your .env.local file or any file that's having this issue, copy the content to clipboard, and delete the file entirely.
Open your .gitignore file and delete the line that removes that file.
Commit your changes (not necessarily publish).
Now create a new .env.local file (or the file you deleted earlier in your case.)
Switch to your Source Control tab (where you see staged files), right click on this newly created file and add it to .gitignore
Now, it will be ignored for real.

Ignore files in a Project to a Fork in Github

I want to ignore some files from a project in Github, so they don't show on my fork.
ex: README.md in another language which I won't use/update, to not show on my project when I Fork it.
Is that possible?
Add that file or directory to your .gitignore file in the root directory and make sure to commit the file.

A folder is mysteriously added into my .gitignore file

I have an Eclipse project which contains only a single folder "MyFolder" containing a LaTeX file "myfile.tex". For some reason, whenever I refresh the project or save a file, the following line is added to the .gitignore file at the root of my project:
/MyFolder
I.e., someone mysteriously tells GIT to ignore the entire folder which contains my tex file. I suspect it's the tex plugin doing this. But why? How can I prevent this?
Try to:
Team → Git → Projects and unmark:
"Automatically ignore derived resources by adding them to .gitignore".