1

I am looking into adding some files to .git repo directory, and push them to the upstream without tracking/commiting them.

Example:

.git/information.txt 

After I do a commit, I add text to information.txt, and then push. When I clone/fork I would like to still have this file in .git.

What I basically want is to have files that are not tracked, and the content in the upstream is updated with the existing content in the local repo when git push is issued.

I guess the way to do it is to hack the git-init and add whatever I want, and see what git push/clone/fork does to the .git folder, and keep the new files and send them to upstream. But I am thinking that maybe there is another way.

Is there a config option that I am missing?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
scas
  • 221
  • 2
  • 9
  • 2
    Why should the information.txt file not be tracked with git? If you want to be able to receive this file when you clone, then it has to be tracked in git. – FlyingFoX Jan 27 '14 at 11:26
  • It is more complicated to explain why. Shortly, it does not interest the user what is in the file, nor has to know about its existence, and therefore it should not be versioned. – scas Jan 27 '14 at 13:03
  • So your problem is that you want to restrict the access of certain users to some parts of your repository, am I right? – FlyingFoX Jan 27 '14 at 13:37

1 Answers1

5

Long story short:

You can't.

The remote repo is more or less a mirror of your local repo.

Git is not a file transfer tool but a version control system.

In order to be able to push something out to the remote repo, the file has to be present (read: versioned) in the local repo.

What you're trying to achive is not possible with Git.

The closest you can get is to have a local branch full that contains the file and another local branch stripped that doesn't hold the file.

If you git push <remote> full, the remote branch will hold the file.

Your work would be done in the stripped branch not holding the file.

But as earlier said: this is basically not something you want to do with Git.

eckes
  • 64,417
  • 29
  • 168
  • 201
  • That was what I thought of doing too. Thanks for explanation! – scas Jan 27 '14 at 13:01
  • @scas Just to be clear: The proposed solution will not allow you to get `information.txt` from the remote repository with a `git clone` as this file will only exist in your local repository. – FlyingFoX Jan 27 '14 at 13:42
  • Sure. I am keeping this branching as an option. However not convinced this is what I want. I am considering other options at the moment. – scas Jan 27 '14 at 14:55