Alireza Noori
Alireza Noori

Reputation: 15253

Using Git without ANY working tree

Suppose you have a bare repository. It contains 3 files:

Now, suppose I don't have the b.txt and c.txt but I have a newer version of the a.txt file. Is it possible to use some command in git and tell it to Update a.txt in the repository, without having to clone/pull the other files? Something like: "Update a.txt in that repository and only look for changes in files that already exist." If not, is there any other version control system which supports this?

Update:

One example for this would be this: A website like github, containing a lot of repositories and a lot of files in each repository. Only, in this website users won't always see the latest revision. They select a revision to see and sometimes they would want to update a file. In this case, the total size of the files would be too much. Considering the users won't always see the latest revision, I think a better way would be to just get a single revision of a particular file on demand and whenever an update is added, add the updated files.

Upvotes: 2

Views: 139

Answers (2)

Chronial
Chronial

Reputation: 70673

You can not that without a copy of the repository – that’s just the way git works. If you want to do stuff to the repository without full access to a full copy of it, git is not the right tool for you. But as I understood from your comments, you do have the repository on your server, and that’s actually where you want to do all the work. You just don’t want to do a full checkout to touch only a single file.

If that’s correct, you are looking for a for a feature that’s called “sparse checkout” in git and is available since 1.7. For more details, see my answere here: How do I clone a subdirectory only of a Git repository? (this question was about sub-directories, but works exactly the same way for single files)

Upvotes: 1

w____
w____

Reputation: 3605

Subversion can do what you want. And for git, there's a similar question: Pull single file on server

Upvotes: 4

Related Questions