NUS Hackers Wiki
NUS Hackers Wiki
  • NUS Hackers Wiki
  • Hackerschool
    • Virtual Machines and Linux
    • Beginners' Guide to the Terminal
      • Introduction to the Terminal
      • Modern Shell Tools
      • Shell Scripting
      • Real World Scripting
      • Resources
    • Self-Hosting: Three Easy Pieces
      • 1. Setting up your server
      • 2. Running Services
      • 3. Monitoring your server
    • Vim
    • Introduction to Zig
      • Language Basics
      • Error Handling
      • Memory Management
      • Working with C
      • Exploring comptime
    • CI/CD with Github Actions
      • Background
      • Basics of Github Actions
        • Target workflow
        • Running unit tests
        • Linting code
        • Deploying to Github Pages
      • Advanced use cases
        • Pollers
        • Github script
        • Executing third-party scripts
        • Reusable workflows
      • Cookbook
    • Lightning Git
      • Git Concepts
      • Getting Started with Git
      • Making your first commit
      • Branching
      • Merge Conflicts
      • Integrating remote repositories
      • Collaborative Workflows
      • Commit Manipulation and Reflog
      • Interactive rebasing
      • filter-repo
  • Orbital
    • JavaScript
      • Browser Developer Tools
      • Getting Started
      • Datatypes
      • Operators and Operations
      • Loops and Conditions
      • Functions
      • Strings
      • Arrays
      • HTML
        • Getting Started
        • Tag Attributes
        • HTML Forms
        • Browser Inspector
      • CSS
        • Selectors
        • Colors in CSS
        • Measurements in CSS
        • The Box Model
        • Adding Styles - Part 1
        • Adding Styles - Part 2
      • Working with the DOM
        • Querying the DOM - Selectors
        • Querying the DOM - Element Attributes
        • Querying the DOM - Element Styles
        • Events with JS and HTML
        • Exercise: Click Counter
        • Editing the DOM
        • Fetch Requests
        • Exercise: The NUSMods API
    • React
      • Setup
      • State
    • React Native
      • Setup
      • Intro to JSX
      • Basic Syntax
      • Handling UI
      • Props
      • State Management
    • Git
      • Setup
      • Command Glossary
      • Fundamental Concepts
        • Getting Started
        • Integrating Remote Repositories
        • Branching
        • Merge Conflicts
      • Collaborative Workflows
        • Fork and PR Workflow
        • Branch and PR Workflow
      • Advanced Concepts
        • Ignoring Files
        • Commit Message Conventions
        • Github Collaborators
        • CI/CD with Github Actions
        • Advanced Git Commands
      • FAQ
    • Telegram Bot
      • Creating a TeleBot
      • API Calls
      • Telebot Basics
      • Integrating API's
    • Relational Database
      • Database Overview
      • Database Design
      • Entity Relationship Diagram
      • SQL Basics & PostgreSQL
    • TypeScript
      • Types and Interfaces
      • Utility Types
      • Typing Component Props, Events, and Hooks
      • Why You Should Avoid Using any (and What to Do Instead)
      • TypeScript Tricks You’ll Use All the Time in React
Powered by GitBook
On this page
  • Using .gitignore
  • Predefined .gitignore
  • What to ignore?
  • Further reading on ignoring files on git
Edit on GitHub
Export as PDF
  1. Orbital
  2. Git
  3. Advanced Concepts

Ignoring Files

PreviousAdvanced ConceptsNextCommit Message Conventions

Last updated 12 months ago

Certain projects may include private files (like secrets) or downloaded content (like dependencies). Such files may contain very sensitive information or very large amounts of data and they should not be included in ANY snapshots of the project.

This is where ignoring files with .gitignore comes into play.

Using .gitignore

To start, let's create a new file secrets.txt:

touch secrets.txt

If you run git status, you will notice that Git prompts you to stage secrets.txt. But we don't want that to happen. So we can add a file .gitignore and add the path to secrets.txt:

echo "secrets.txt" >> .gitignore

Then, when you run git status again, you will notice that Git no longer prompts you to stage secrets.txt. Wonderful!

Predefined .gitignore

You can find a set of predefined .gitignore files here:

We highly recommend going with them for any project so that you are not redefining/missing any common files and folders that should be ignored.

When creating a repository on Github, can select a predefined .gitignore to be added in the repository so you can save a step of adding the file

What to ignore?

Typically, we ignore files like build artifacts and generated files that are usually derived from the human-authored code in the repository.

  • Dependency caches like /node_modules

  • Compiled code like .o, .pyc files

  • Build output directories like /bin, /out

  • Runtime-generated files like log files

  • Personal configuration files e.g. of your IDE

Further reading on ignoring files on git

https://git-scm.com/docs/gitignore
https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
https://github.com/github/gitignore