Giter Site home page Giter Site logo

test-git-sparse-checkout's Introduction

test-git-sparse-checkout

First do the following

  1. Clone this repo with git clone --filter=blob:none --no-checkout
  2. git sparse-checkout init
  3. git sparse-checkout add README.md
  4. git sparse-checkout reapply
  5. git checkout

Now there should be just a single README.md in project root.

Now, say you want to add a new file stuff.txt in folder1:

  1. mkdir folder1

  2. touch folder1/stuff.txt

  3. A naive git add folder1/stuff.txt would produce the following error:

    The following paths and/or pathspecs matched paths that exist
    outside of your sparse-checkout definition, so will not be
    updated in the index:
    folder1/stuff.txt
    hint: If you intend to update such entries, try one of the following:
    hint: * Use the --sparse option.
    hint: * Disable or modify the sparsity rules.
    hint: Disable this message with "git config advice.updateSparsePath false"
    
  4. To actually add the file, follow the first hint provided by git:

    git add --sparse folder1/stuff.txt
    
  5. However, after you do a git pull, folder1/stuff.txt will vanish.

    • If stuff.txt is actually a folder, you can tell git to keep it with git sparse-checkout add stuff.txt and git sparse-checkout reapply.
    • Otherwise, force adding it will make ALL files under folder1 available.

Above is tested with git version 2.38.4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.