Good morning everybody! When I try to add a .gitignore to my project it’s always in .txt format. I tryed to do directly in the diretory, with commands (some tutorilals sugest doing that with command touch, but it’s not available in windows and there’s no good substitute for this command) and even with VS code. Some research on the web didn’t help me a lot, so I ask you folks: did someone ever had a problem like this or can think of a solution?
I don’t understand. Is this part of a challenge?
In a normal environment, you should be able to just create it with your editor or touch it.
When I try to add a .gitignore to my project it’s always in .txt format
It should be a text file but should not have the txt extension. Can you not remove the extension.
some tutorilals sugest doing that with command touch, but it’s not available in windows
I used to use it all the time in the terminal window on Windows.
even with VS code.
Wait, what? You should be able to create it or change the extension easily in VSC.
There must be something I am not understanding because what you are saying doesn’t make sense to me.
touch
is not a native Windows terminal command. If you install Git for Windows you get Git BASH which does support touch
.
When you create a file in VS Code it should not have any file type until you actually give it one. I’m not sure how or why it would automatically add the .txt extension to files.
If nothing else works for you, you can try this VS Code extension. Just right-click the file or folder you want to add to the .gitignore and select the “Add to .gitignore” menu option.
There is also this extension which let you create one based on the https://github.com/github/gitignore
repository (F1 and start typing Add gitignore
)
Both are named gitignore so if you search for that in the VS Code extensions it will be the first two results.
It sounds like you can see the extension but just to be sure check the settings (you may be getting double extensions).
Yeah, I was probably using BASH.
There are a few different options on Windows but most of them do not work as touch (i.e. update timestamp of an existing file)
Power Shell: New-Item (should work with the ni
alias)
ni .gitignore
Yeah, that’s what I’m trying to discover. Touch really worked on bash here, but the problem is te same: The file is being created as txt. Am I able to turn a txt file in a gitignore someway?
As said, just remove the .txt extension. The .gitignore file is a text file it just doesn’t have a file extension.
If you are saying when you run touch .gitignore
it creates a file named .gitignore.txt
that just sounds broken. Might be caused by damage to the registry or malware. It definitely is not normal behavior.
Open Notepad and from the File
menu, select Save as
. Use the dropdown next to “Save as type” and select All Files (*.*)
. Write the file name and surround it in quotes like so ".gitignore"
save the file and you should see a file name .gitignore
with no file extension. If it still gets the .txt extension something is definitely broken on the system.
https://www.google.com/search?q=windows+reset+file+extension
It worked, thank you!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.