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

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.

Related

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

how to rollback the ignore state of a file/folder in git using eclipse

accidently I set the ignore state for a folder in GIT in eclipse.
context-menu on the folder -> team -> ignore.
How can I activate this folder for GIT again ?
I guess it must be team -> add to index, but this doesn't work for me.
any help ?
Click Ctrl+shift+R and type .gitignore in eclipse.
Open the .gitignore file of respective project.
All the ignored file's path will be displayed here.
Now remove the paths of files which you want to unignore and save it.
Again the files will be back to its original stage and can be added to staging area.
Steps to make file unAssumed ignore
If you don't want your files to be ignored then do the following
Go to the file you don't want to be ignored and rightclick it --> Team --> Advanced --> No Assume Unchanged
Please find the same in image
See this bug right now there is no way to find all ignored resource in a git repo using EGIT.
When you do Team context-menu on the folder -> team -> ignore it will automatically create a .gitignore file inside the parent folder and this file is added automatically to git index and will be shown in git staging view.
After committing this file it is difficult to find all ignored resources in a given git repo. Go to your file explorer and search for all .gitignore files inside a git repo and view their content.
In the base directory of the git project, there will be a file called .gitignore (Note the dot at the start of the filename).
This file lists all the files, directories etc that are ignored by git.
Simply edit that file, removing the line which corresponds to the folder you accidentally added.

How to ignore files via GUI in Gitkraken?

I come from SourceTree to board the GitKraken hype train. It has always been pretty easy to ignore files within ST. Just right-click on a file in the unstaged container and you've all the options. You can ignore the files directly, each file beneath a specific folder etc. (so, all the .gitignore stuff from within the GUI =)).
However, I can't find a similar feature in GitKraken. Does anybody know how I can ignore files via the GUI of GitKraken?
Please note: This is not a git question. I absolutely know in depth how ignoring files in Git work. But that's not the topic whatsoever. This is just a trivial GitKraken support question.
Currently there isn't an option to ignore a file through the GitKraken GUI.
If you check their post on twitter this is planned to be implemented soon and it will be in their release notes once this is completed.
UPDATE (26.01.2017.):
Version 2.0.0 brings the .gitignore option to the list of functionalities. You can now select a file or folder in the file staging area, and add to the .gitignore file on the fly. Right-click and select Ignore. From there, you can:
Add that specific file to .gitignore
Add all files with that file extension to .gitignore
Add all files in the same folder as the selected file to
.gitignore
(If selecting a folder) add that folder to the .gitignore

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

can't commit code after renaming a file

What I did:
renamed a file
tried to commit
cvs fails with error message
file should be removed and is still there (or back again)
What is the problem and how do I solve it so that I can commit?
Additional information:
I'm using Eclipse with the CVS plugin.
doing an ls in the directory where the file was shows that it is not there
All the other Google hits for this problem (including this question) seem to be asking what to do when a file has been removed with cvs, and then restored outside of cvs' scope. My problem is different: I just need to rename a file.
It means that the file was flagged for deletion by CVS but then appeared again. Renaming for CVS is just a deletion of the file with old name and adding the file with new name. The file must be appeared again with its old name.
You can do 2 things:
1) If you don't need this file then just delete it. (Use cvs -n update command to find its name.) Then you will be able to commit.
1) if you need this file to stay, go to the .CVS subfolder of the folder where the file is located and edit Entries file. Find a line with your file and delete it. Then rename you file (give it a temporary name), call cvs update, rename your file back overriding the new one appeared after cvs update.