Git - MariMendM/devops-sandbox GitHub Wiki

Git

Page of tips and how-tos for Git.


Git Sparse Checkout

Steps to perform a sparse checkout from a single subfolder of a given repository, using Git Bash (ex.: Project001 from https://github.com/MariMendM/devops-sandbox):

  1. Create a directory:
    mkdir /home/ubuntu/devops-sandbox
    cd /home/ubuntu/devops-sandbox
    
  2. Start a Git repository:
    git init
    
  3. Track repository:
    git remote add -f origin https://github.com/MariMendM/devops-sandbox
    
  4. Enable the tree check feature:
    git config core.sparseCheckout true
    
  5. Create a file "sparse-checkout" in the path ".git/info" (the hidden folder ".git" was created by 'git init'):
    touch .git/info/sparse-checkout
    
  6. Edit created file to input the name of the sub folder to be cloned:
    echo 'Project001' >> .git/info/sparse-checkout
    
  7. Download with pull, not clone:
    git pull origin master