I have a really old install of Debian on my Thinkpad, and I want to refresh it now that I'm using it again. However, I have a LOT of old scripts all over this install for beauty fixes, shortcuts, and keybinds.

These scripts are in various locations all over the install, and I want to send them all to a single 'catch-all' repo in github to save/share in case I need them, sort of like an online folder. But seeing as git's general purpose is to track changes in projects, I'm not sure how to do this without pulling the entire repo into my working directory, committing the files I want, and then pushing the whole thing back.

Is there a way to just send individual files to a repo without having to pull the whole repo? Am I wrong in trying to use github for this purpose?

  • 2
    I would recommend you to use a regular cloud service instead, such as google drive. You are indeed not choosing the best tool for what you're trying to achieve. – Andy Feb 26 '16 at 19:13
  • 1
    The magic word you're looking for is "sparse checkout", which git does support. But as David said, git may not be the right tool for this. – Ixrec Feb 26 '16 at 19:21
  • are you looking for git add /path/to/file? ... alternatively github now supports drag and drop files – technosaurus Feb 27 '16 at 15:34

It's certainly not the intended use case for most version control systems, but if the OS supports it for the files in question, I would mirror the structure you want to preserve in a git repo in your home folder, move the files you want to track there, and write a small script which creates symlinks in the real locations for all of the files. Edits in the real locations will end up in the git repo and you can track everything the way you want.

I've used this approach successfully over several computers, even with different OSs, to track various dot-files, and configurations in my home-folder over the years, without having to create a git-repo in ~.

There may be security related caveats if the system or various programs disallow their expected files to be symlinks, but then you could try syncing those individual files instead of linking them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.