Turn off automatic git repo creation when using your own project template

template

#1

Hi all,

I created a very small and naive project template for my students, but when testing it out I found out that this will automatically create a git repository if you have git enabled in the RStudio options. This is overkill, as we’re talking about a project template they need for homeworks and their thesis mainly. I know there’s other and better ones, but they also require a better understanding of all the dev tools.

I’ve looked above and beyond, but I can’t find any documentation on how to tell RStudio to not do that. Preferably I would add a checkbox like in New Project > New Directory > New Project saying “create a git repository”. Anyone knows what I have to add in the .dcf (and possibly other files) to make that happen?

Cheers
Joris

PS: This is my hideously naive simple template : https://github.com/JoFAM/daprojects
Feel free to add an issue if you have ideas for improvement.


#2

Hi @jorismeys,

When you want to create a new project in RStudio, they is already a box you can check or uncheck
image

If you uncheck this box, no git repo is created. RStudio should not init a git repo automatically unless this box is checked by default.

Update you RStudio version if you do not have the new one, and check if you have this box.


#3

@cderv Obviously, and I mentioned that. But that was not the question. Try that with the custom template I provided, and one of two things happen:

  • if git is not enabled in RStudio, the project is created as a normal project.
  • if git is enabled in RStudio, the project is always created as a git repo.

I need something in the api for custom project templates that allows me to add that checkbox to my own custom template.


#4

Sorry for giving you an obvious information, I misunderstood.

I cloned your repository, devtools::install your package. Then I restarted RStudio, Opened a new project with your template. The new created project has no .git folder, and is not a git repository by default. Git is enabled in RStudio (Tools > Global Options > Git/Svn).

BTW i am on Windows.

It seems I can’t reproduce the issue.

I suppose you add a checkbox for git and bind to a function that would to a call to init a git repo or not.


#5

@cderv Thanks for testing that. I checked and if I start from an empty project, I have the same behaviour. The culprit seems to be when I start a new project from a project that has a git repo. In that case the new repo will have a git repo as well, at least on my machine.

I would like to add that checkbox in the dcf file, but I can’t find where and how. So I’m back at my original question :slight_smile:

I checked : https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html

but there’s not enough information to help me further.


#6

You mean if I enter a random project with git in RStudio, then make a new project from there with Files > new project > New directory > Basic Project for Data Analysis ?

I tested that and it works me too. No git repo created.

About the checkbox, you already add for readme and example file. What are you expecting different from a new checkbox called git ?
When this one is true, you may do a system call git init in setup_dap ? maybe not the cleaner but should work with right test for git existence. (I looked in rstudioapi, but did not find any function about VCS)


#7

@cderv That’s weird, at my computer it keeps creating git repos. I do start from a .git package repo (the repo of daprojects actually). Hadley just said he believes it is related to another issue that was solved very recently. See also : https://github.com/rstudio/rstudio/issues/2075

What I would like, is just have the same “create a git repository” checkbox as in the default New Project dialog. It should be possible to do without system calls, as a system call would use my other git, is dependent on the setup of the user and might not be compatible over all different OS setups.

I’ll experiment further and see where I get. Thx for the help!


#8

Yep that is odd.
Thanks for cross referencing, that’ll help following. I let you deal with this issue there. If you need further testing, ping me. It is also @cderv on GH.


#9

Thanks for the bug report. I think RStudio is using the ‘saved’ value of the Create a git repository checkbox (as used with the most recent project creation) used in the other ‘New Project’ dialogs. I was able to reproduce the behavior you’re seeing with:

  1. Create a New Project using the default ‘New Project’ template entry, and check the Create a git repository box.

  2. Next, create a New Project using one of the project templates provided by one of the installed packages.

  3. Observe that RStudio automatically initializes a Git repository for the newly created project.

We should make this checkbox visible for other project templates, so that the behavior can be customizable with other projects as well.