1

im pretty new to use github and have to find a solution for a problem. i start all my git project from a skeleton which i keep in a github repository. it have stuff like licence, gitignore and so on in it.

right now i start cloning my skeleton into the folder of the new project.

git clone https://github.com/myskeleton new-project

then i add all my files and start new with a rm -rf .git and git init. but i update my skeleton project now and then and would like to pull / fetch these updates in the new project.

i hope you understand my need and maybe can give me a hint how to solve this problem in a better way im doing it right now.

thanks for answers

cheers bin2hex

bin2hex
  • 345
  • 3
  • 15

1 Answers1

3

You can use the native git feature git init --template=path/to/template/dir.

You can define a default template dir in your .gitconfig file

(You are free to use git (or/and github) to manage that directory but that's optional.

see git help config and git help init for more detail about that feature

Asenar
  • 6,732
  • 3
  • 36
  • 49
  • holy moly this sounds good. i will check this out right now! but what you wrote seems to be only the solution for the initial setup. what happends in case i change my template folder, is there a way that i can pull this updates inside the existing project as well? – bin2hex May 23 '16 at 16:14
  • I don't think you can do that. Let's say you start a project with that license, then you start to work, then you want to change your license. this require a new commit. The alternative is to rewrite the history with `git rebase -i` but this is obviously not recommended for a public project. An even worse solution would be to put all theses files into a «`doc` directory» and manage it as a submodule. Side note: when doing `git init` on an already existing repository may copy new hooks, but I'm not sure (just test it :) ) – Asenar May 23 '16 at 16:22
  • ok i get a bit more specific. in this skeleton are also markdown files, and shell scripts. so when i start the project running the shellscript which ask me for licence and stuff to create the basic structure. inside there are also markdown templates which link to pages, accounts and so on. just think about it like a website template. i created this in case i change there something in my kind of signature with my links that i can do this quick for all the projects. that i have to add these changes and commit them again is not a problem. but i have to pull these changes to the current project. – bin2hex May 23 '16 at 16:28
  • 1
    You can have a small repo containing shellscripts (and add it as a submodule, even in your template repo), but separately from license and stuff like this. When you use git for a project, every changes are commits. So if the license changes, it requires a new commit (and it's a good thing). Otherwise you can also add a link in the readme to all up to date information. I personally use the same structure when I start a new project but as I don't create one every day, I don't feel the needs to have a template thing. – Asenar May 24 '16 at 06:38
  • I've not so much about that on my github (link on my profile page). You can check my `dotfiles` repo which contains useful git config and alias (+ some stuffs for `vim` and `i3` config). If my answer suits you, you can validate it (below the votes buttons) so next time someone see that question he will jump to the right answer easily (and welcome on SO by the way :) ). – Asenar May 25 '16 at 07:53