How to translate a directory named "A" with src files in it to a package named "B.jl" using PkgTemplates without loosing the git commit history?

The situation is that I have recently decided to use PkgTemplates and would like to adapt some directories where I have been coding (neither of them is yet a package but they will be).
Maybe this is a basic git question without relation to Julia?

Set up B.jl as a package, and then copy the source files over from A. That’s it.

Thanks. Do you consider the local .git/ directory as source files? I thought that within the .git/ directory there was the information about the old directory “A”, for example the github url of directory A.

If you want to retain git history it seems more natural to copy in the opposite direction.

Thanks. Could you give an example so I understand what you refer to?

Run PkgTemplates in some empty directory, then copy the generated files over to your code directory. Possibly you want to configure PkgTemplates not to push things to github but handle that yourself. Whatever git history PkgTemplates creates is in any case of no particular interest compared to the git history of your code.

Thanks! You mean I copy everything generated by PkgTemplates but not the .git/ directory? In that case I would have to go on with a directory named “A” right?

You can rename files and directories as you want. The only requirement from the package manager is that the name in Project.toml has a corresponding file src/$(name).jl and that file creates a module of the same name.

And yes, skip the .git directory generated by PkgTemplates.

Yes, I would copy that as well. Overwriting the .git in B.jl.

Thanks for you answer. Is it possible that I should manually edit the url line inside the file .git/config in order to update the github repository?

Thanks @GunnarFarneback ! I will try in both ways. The problem I see is that I want my PkgB to be in .julia/dev/ but not located in the directory A.

You can but the usual way to manipulate that is with git remote set-url.

Move the package directory or make a new clone in .julia/dev. Not that there is any particular advantage having your package in .julia/dev.

1 Like

Thanks a lot.

For the moment I will start by locating the development packages in .julia/dev/ but I would like to know for the future, how do you do otherwise. How does Julia know where is the package when doing ] dev MyPkg ?

Use the local path with ] dev. Most of the time when I develop packages I just activate them (usually with julia --project) though.