RichiH / vcsh

config manager based on Git
GNU General Public License v2.0
2.2k stars 124 forks source link

Add a file from another git repository #330

Open TimotheeMathieu opened 1 year ago

TimotheeMathieu commented 1 year ago

I use vcsh as an archiving tool, adding and commiting important files throughout my laptop.

My problem is that some of the files I'd like to archive are already in another git repository. I don't want to add this git repo as a submodule because this is a bit of a pain and some of these git repo are local anyway so having a submodule for this do not really make sense.

Basically my question is: is there a way to allow vcsh to add files from a folder that contains a .git ?

Thanks.

alerque commented 1 year ago

Did you try just force adding it?

TimotheeMathieu commented 1 year ago

Yes, I tried vcsh repo add --force file but vcsh status stays empty.

RichiH commented 1 year ago

I thought this should work. What error message do you get? What error code?

Message ID: @.***>

alerque commented 1 year ago

I did give this a try and it didn't work as I expected it would either. No error, no code, just a silent fail to do anything at all. None of my system layouts run into this circumstance since all my VCSH things are carefully kept upstream of any actual Git repos, but I guess it should be possible to do if you really wanted to.

Just brainstorming here, but this may have to do with recent changes to Git's security precautions, although I would have expected an error...

jakebman commented 1 year ago

Temporarily renaming the .git folder of the "donor" repository seems to be a temporary workaround if you need it, @TimotheeMathieu. Once the file is tracked by your vcsh repo, it remains tracked even if its contents change.

This appears to be submodules behavior trying to step in and getting confused. Adding the root directory of the donor repo seems to produce a cleaner error:


warning: adding embedded git repository: projects/vcsh
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint:   git submodule add <url> projects/vcsh
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint:   git rm --cached projects/vcsh
hint:
hint: See "git help submodule" for more information.