0

how to Download single file/folder from a Private GitHub repository hosted on GitHub. The repository structure is like

AndroidApps/
├── FirstAnimation/ 
│   ├── app
│   └── build.gradle
|   └── gradle.properties
|   └── ...
|
└── NavigationHelp/
|   ├── app
|   └── build.gradle
|   └── gradle.properties
|   └── ...
|
└── ChatApp/
    ├── app
    └── build.gradle
    └── gradle.properties
    └── ...

And I want to download only the NavigationHelp folder and not clone the whole AndroidApps project.

note-(previously answer given on Stack overflow related to public folder which does not work for private repo)

Kalyan Mishra
  • 25
  • 1
  • 7

2 Answers2

2

Here is what you can do to download a single file/folder from GIT repository without having to clone the entire project:

As asked: a) you can download a single file. Or b) you can download a single folder (with all its files - without having to clone entire project).

To download individual file: using following steps to download a single file from GITHUB website:

  1. After signing in to the Github.com, -> open your Repository, -> open the target folder, -> click on "Go to file": enter image description here

  2. now right click on the target file and -> click "Save link as": enter image description here

To download all project files with its folder-structure: To download all files & folders, log in to GIT online -> open the target project -> click "Code" dropdown and select "Download ZIP", this will download entire project (as zip file): enter image description here

HTH.

Eddie Kumar
  • 1,216
  • 18
  • 20
1
git clone -n --filter=tree:0 git@github.com:your/AndroidApps
cd AndroidApps                   # <--- forgot this line the first time, oops
git read-tree -um @:NavigationHelp

will get you just that folder and the barest sketch of the rest of the history. To make future pulls work,

git checkout -b sliced/NavigationHelp
git config branch.sliced/NavigationHelp.merge @{-1}@{u}
git config branch.sliced/NavigationHelp.mergeoptions -Xsubtree=NavigationHelp

and that'll let you pull updates but not merge back to the upstream branch. Read up on the commands and syntax I've used above and you'll learn to adapt this to check out anything else.

To merge back to the upstream branch, you'll either have to fetch it and do the merge yourself or convince GitHub to support subtree merges done on its servers, (if they don't already, I've never investigated).

jthill
  • 55,082
  • 5
  • 77
  • 137