Skip to content

yoann9344/git_clone_directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Extract a github directory

Clone only a subdirectory from Github without creating or replacing the .git/ config ! If a file already exist ask if you want to replace it.

Installation

# Requires "requests"
pip install requests
# Clone this repository somewhere
mkdir -p ~/bin/ && cd ~/bin/
git clone https://github.com/yoann9344/git_clone_directory.git && cd git_clone_directory/
# Add right to execute
chmod +x github.py
# then link github.py to your $PATH
# example link in /usr/bin with name github
ln -s ~/bin/git_clone_directory/github.py /usr/bin/github

# then to update
cd ~/bin/git_clone_directory/ && git pull && chmod +x github.py

Command Line Interface

github [OPTIONS] GITHUB_DIRECTORY [PATH]

Github_directory

Github link to a directory, following this regex :

(https://github\.com/([^/]+)/([^/]+)/(?:tree|blob)/([^/]+))/(.*)$

Path

Directory where the github subfolder will be retrieved (default='.')

Options

The options can't be group (-vd won't activate neither debug or verbose mode)

-d, --debug => Debug mode

-v, --verbose => Verbose mode (show each extracted file)

-y, --yes => Say yes to all questions (will replace existing files)

-n, --no => Say no to all questions (will not replace existing files)

-t, --tar => Simply save a tar.gz without uncompressing it

Examples

# Copy content of directory '/path/to/subfolder' from this reposistory to the current directory
# will copy nothing because the '/path/to/subfolder' does not exist in this repo
github.py https://github.com/yoann9344/git_clone_directory/tree/main/path/to/subfolder

# Copy content of directory '/plugin' from the vim-regex-syntax's repo to the ~/.vim/plugin
github.py https://github.com/Galicarnax/vim-regex-syntax/tree/master/plugin ~/.vim/plugin/

# Copy content of directory '/plugin' from the vim-regex-syntax's repo to the ~/.vim/plugin
# Replacing all existing files without asking with a verbose mode
github.py -v --yes https://github.com/Galicarnax/vim-regex-syntax/tree/master/plugin ~/.vim/plugin/

# Copy content of directory '/plugin' from the vim-regex-syntax's repo to the ~/.vim/plugin
# using a specific commit (4cdebc1893b2a013c5af4057102d393321855a4e)
github.py https://github.com/Galicarnax/vim-regex-syntax/blob/4cdebc1893b2a013c5af4057102d393321855a4e/plugin ~/.vim/plugin/

# Same but copy only the file "regex.vim"
github.py https://github.com/Galicarnax/vim-regex-syntax/blob/4cdebc1893b2a013c5af4057102d393321855a4e/plugin/regex.vim ~/.vim/plugin/

# Extract this repo in a tar.gz
github.py -t https://github.com/yoann9344/git_clone_directory/tree/main/

About

Clone a subdirectory from Github to the given path

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages