Home > Mobile >  Is gitignore a file types or something that can be added on to files? Can I change a .txt file to .g
Is gitignore a file types or something that can be added on to files? Can I change a .txt file to .g

Time:06-01

I'm new to github and recently created my first repo. I was wondering if gitignore is a completely different file type, or can it be added on to other files.

If gitignores can be added on to other files: I have a .txt file called words.txt. How do I change this into a .gitignore.txt file?

If gitignores are a completely different file type: How are gitignores helpful and where can they be used?

Thanks!

CodePudding user response:

Gitignore files are a specific file type.

When you’re working in your copy, Git watches every file in and considers it in three ways:

  • Tracked: You’ve already staged or committed the file.
  • Untracked: You’ve not staged or committed.
  • Ignored: You’ve explicitly told Git to ignore the file(s).

The .gitignore file tells Git which files to ignore when committing your project to the GitHub repository. gitignore is located in the root directory of your repo.

The .gitignore file itself is a plain text document.

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/ 
  • * is used as a wildcard match *.exe will ignore any file with the .exe extension
  • / will ignore directories with the name. vendor/ ignores the vendor directory.
  • # will comment the line
  • […] will ignore values with any of the values. *.[abc] ignores files file.a, file.b, file.c. .[a-.[oa]d] the dash will include a range, in this case, file extensions a-d.

You may want to ignore certain files for multiple reasons:

  • The files contain sensitive data.
  • The files are system specific and do not need to exist on every machine’s copy.
  • Excluding the files maintains system security rules and privileges. (Remember, Git repos only contain the files necessary to get tech support—not to share the entire software.)
  • Binary, build assets, environment related..

Source: https://www.bmc.com/blogs/gitignore

  • Related