elmarco
elmarco

Reputation: 33073

Local clone with modified files with Git

I am looking for a way to copy the modified / uncommitted changes in the clone destination (staged or not).

git clone --shared src dest

It would be nice to have a --modified, or would that be a bad idea?

Upvotes: 0

Views: 102

Answers (1)

poke
poke

Reputation: 388403

You cannot do that, and it would be a really odd thing to do. Git’s datamodel works on the base of commits, and whenever you transfer data between a local and a remote repository, you are essentially copying commits and labels around.

This inherently means that in order to transfer anything to a different repository, you need to commit those changes. And that is a good thing because a commit is a fixed and unchangeable thing in a repository. Uncommitted changes are not, so it’s incredibly difficult to reference them properly. It would be a huge mess. In addition, you would be breaking the intention behind committing completely, since you could suddenly transfer changes without committing, without making the deliberate choice to “seal off” a package of changes with author information and an explanation.

Finally, when cloning in particular, you are cloning a remote repository. In most situations, such a remote repository is a bare repository and as such has no working directory. As such, it would also have no way of having uncommitted changes anyway.

So no, it would not be a good idea, and it would also likely not work properly anyway.

Upvotes: 1

Related Questions