I Have the following files:
And I want to commit only:
How to ignore .js files that are the same name as the .ts files?
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
There is no explicit git ignore command: instead the .gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.
outDir
entry of your tsconfig.json
file. This is conventionally called build
but you can name it whatever you'd like.// tsconfig.json (mine is in the root directory of my project)
{
"compilerOptions": {
...
"outDir": "myAwesomeSuperCoolBuildDirectoryThatIPromiseToChangeAndNotJustCopyBlindlyFromStackOverflowBecauseThatWouldBeBad",
"sourceMap": true,
...
}
}
outDir
followed by a forward slash --> /
to your .gitignore
file// .gitignore (mine is in the root directory of my project)
myAwesomeSuperCoolBuildDirectoryThatIPromiseToChangeAndNotJustCopyBlindlyFromStackOverflowBecauseThatWouldBeBad/
js.map
and js
files generated by TypeScript and build them again. This time, they will be built in the specified directory and will be ignored by git.For your particular case, I suggest:
In .gitignore
*.js
!_*.js
This will ignore all js files except what starting with underscore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With