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.
Project01
Project02
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.
A) skipping the target subfolders:
add a .gitignore file containing this line:
target/
to the respective subfolders that contain a "target/" folder.
OR you can add "target/" to your global ~/.gitignore. (because you will most likely never check buildfiles into git (same applies to "build/" if you use gradle obviously)
see https://git-scm.com/docs/gitignore for deeper explanation
There are multiple gitignore generators and templates out there. (e.g. i created my global gitignore file on https://gitignore.io, adding eclipse and idea folders, keystore file-endings and more)
B) "uploading" nested git repos
the most probable answer is: don't.
theres multiple possibilities of what you want to achieve:
either you have separate "Project" repositories that can be versioned on their own without depending on the other, then use independent git projects
if they depend on each other, it might be easier to create one single monorepo (your top level "Repo", then you just need a .git folder ("git init") "up" there, but not inside either project
if you want to keep the two repos inside the other one (logically), you might want to create them outside of the top lvel repo (on your file system) as independent projects, and then create the top level repo next to them and integrate them via submodules or subtree. https://git-scm.com/book/en/v2/Git-Tools-Submodules (however this makes git much more complicated and is probably overkill for your setup)
my personal recommendation would be: use version 1, since your setup looks like two separate maven projects, which should probably be independent from each other anyway. if they need to be nested, you might want to fix your maven setup first.