-1

Say I have a single script that I want to git. From what I know, I have to create a folder which will contain this script and .git.

  • Is there a way to only have the script itself? This would mean having some sort of header/footer to handle git stuff.
  • If not, another option would be to have a single extra file to handle git.
8
  • git-scm.com/docs/gitrepository-layout Commented Jul 28, 2018 at 11:15
  • Maybe if you don't like how Git works you should consider alternative sourcecontrol systems? Commented Jul 28, 2018 at 11:23
  • @JohannesB I like git this is why I am trying to see if this can be done. Commented Jul 28, 2018 at 12:00
  • @juzraai what do you want to say? Commented Jul 28, 2018 at 12:01
  • I'd assume the down votes are signaling the question shows too few research on the subject before asking. Also, you don't give any context to your question, which leads right into XY problem territory... Commented Jul 28, 2018 at 12:41

2 Answers 2

1

One way to achieve a version controlled single-file-in-otherwise-empty-repo is to have a bare repo somewhere, and then check it out to the folder in which you want only a single file.

As explained here

To checkout everything from your HEAD (not index) to a specific out directory:

git --work-tree=/path/to/outputdir checkout HEAD -- .

Sign up to request clarification or add additional context in comments.

1 Comment

That should do the trick. This way I can have a folder with several scripts. Each of the scripts being under a different git.
0

The .git is integral to the way git works and stores information. You would need it in some way to use git.

If I understand you correctly, you want a script under version control but the folder the script is contained in must be empty.

To that end, we could create a git repository in the parent folder, with the subdirectory having nothing but the script.

parentDirectoryUnderVC/ .git/ myScriptProjectWithOnlyMyScriptInIt/ myScript.whatever 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.