What is syntax for ignoring a directory in Git?

When I want to add an entire directory to my .gitignore, what is the syntax? The directory-to-ignore is in my root directory.

Should it be:

  • Git commit lost after reset --hard. Not found by fsck, not in reflog
  • How to remove big files from old commits in bitbucket
  • How to run post-receive hook on GitHub
  • How to set Git config options for all subdomains?
  • Hg-Git: How to push to both Github and Bitbucket?
  • SourceTree ssh-agent failing after update
  • 1) directory-to-ignore

    2) directory-to-ignore/

    3) directory-to-ignore/*

  • Does GitHub for Windows work with GitLab?
  • Pushing to multiple git URLs with set-url and its pitfalls
  • What's the difference between post-receive and post-update?
  • Git log pretty format, newline after placeholder if non-empty
  • Git revert not bringing back the earlier state
  • Git merge strategies: spaces make default shows no conflict and bring unexpected results
  • One Solution collect form web for “What is syntax for ignoring a directory in Git?”

    just add the directory to the .gitigore like:

    .gitignore file:

    directory-to-ignore/
    

    so, option 2 is correct

    Git Baby is a git and github fan, let's start git clone.