15706

git clone. How to clone local repo by hardlinks?

I have a local git repository. I want to clone it on the local machine by hardlinked files to save disk space. How can I do it?

Answer1:

a Git repository is made, by simplification, of <strong>3 kind of files</strong>:

<ol> <li>

<strong>Database-like objects</strong> ($GIT_DIR/objects): These objects are never modified, some can be added, some can be removed, but the files are never modified. It means that they can be exactly the same between many clones.

</li> <li>

<strong>repository-specific configuration and status</strong> ($GIT_DIR): These files contains configuration specific to the repository ($GIT_DIR/info/* for example). They also store the repository status, like what are the known branches, what is the checked-out branch, etc. They can't be shared between repository, or that would be against the design

</li> <li>

<strong>working copy files, or source</strong>: These files are most of the time your source code, they are meant to be different from one repository to another. They are flexible and change a lot (either because you code a lot, or because you switch branches a lot, or both).

</li> </ol>

As a matter of fact, the only non-changing, not repository-specific files are object files. And these are automatically hard-linked by Git if possible (even without specifying -l).

If you want two repositories on the same drive to have the exact same status and files, then you should definitely make a symbolic link. But you can't hard-link configuration and working copy files because they change too much and are specific to the repository.

Recommend

  • Heroku + Grails - missing DATABASE_URL when building app on heroku
  • Find path to git hooks directory on the shell
  • cannot load gems in test environment
  • php show all images in directory and sort by last modified
  • EF 4.1 DBContext AutoDetectChangesEnabled
  • Unzip archive in .Net CORE 1.0
  • What is corresponding c++ data type to SQL numeric(18,0) data type?
  • Building Qt project for C++11 standard
  • How to get data from **Realm database** using **date object**?
  • Do query loads all the data in memory
  • uml Composition relationships to RDF and OWL
  • Owin Authentication and claims in asp.net how to access user data
  • Javascript, Regex - I need to grab each section of a string contained in brackets
  • Sending HTML Form Data to Spring REST Web Service
  • Install PHP intl extension on MacOS
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • Debug.DrawLine not showing in the GameView
  • How can I sort a a table with VBA with given text condition?
  • How to define and use opencv mat of user type
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Use of this Javascript
  • MongoDB in PHP using aggregate to group by _id is null not working
  • How to rebase a series of branches?
  • CSS Linear-gradient formatting issue accross different browsers
  • How do I change content of ComboFieldEditor?
  • How to extract text from Word files using C#?
  • How to check if every primary key value is being referenced as foreign key in another table
  • Sending data from AppleScript to FileMaker records
  • Cassandra Data Model
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Updated Ionic CLI but shows previous version (Windows)
  • Weird JavaScript statement, what does it mean?
  • How do you troubleshoot character encoding problems?
  • Do I've to free mysql result after storing it?
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • SQL merge duplicate rows and join values that are different
  • Understanding cpu registers
  • Getting Messege Twice Using IMvxMessenger
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Python/Django TangoWithDjango Models and Databases