Recursively add the entire folder to a repository

后端 未结 15 1356
野的像风
野的像风 2020-11-30 16:23

I am trying to add a branch to the master branch on GitHub and push a folder onto that branch.

The folder structure of the branch looks like - SocialApp/SourceCode/D

15条回答
  •  抹茶落季
    2020-11-30 17:02

    Scenario / Solution 1:
    Ensure your Folder / Sub-folder is not in the .gitignore file, by any chance.


    Scenario / Solution 2:
    By default, git add . works recursively.


    Scenario / Solution 3:
    git add --all :/ works smoothly, where git add . doesn't (work).
    (@JasonHartley's comment)


    Scenario / Solution 4:
    The issue I personally faced was adding Subfolders or Files, which were common between multiple Folders.

    For example:
    Folder/Subfolder-L1/Subfolder-L2/...file12.txt
    Folder/Subfolder-L1/Subfolder-L2/Subfolder-L3/...file123.txt
    Folder/Subfolder-L1/...file1.txt

    So Git was recommending me to add git submodule, which I tried but was a pain.


    Finally what worked for me was:

    1. git add one file that's at the last end / level of a Folder.
    For example:
    git add Folder/Subfolder-L1/Subfolder-L2/Subfolder-L3/...file123.txt

    2. git add --all :/ now.
    It'll very swiftly add all the Folders, Subfolders and files.


提交回复
热议问题