'Git how to upload whole directory with subfolders?

So I am currently learning how to use Git.

I can upload to Github normally. However I now have my local repo structured like this.

  • Repo
    • git
    1. Project01

      1. .git
      2. src
        • main.rs
      3. target
    2. Project02

      1. .git
      2. src
        • main.rs
      3. target
    • README.md

My question is how can I upload this structure while ignoring all directories named target ? I have one repo and two seperate projects inside it. I want to be able to upload whole Repo with one command.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source