Start new R package development on github

久未见 提交于 2019-12-02 16:50:54
Tomas Greif

Hope this helps someone:

  1. Create empty repository on github (I will use name rpackage in this example)
  2. Create package locally using devtools, create("rpackage") (this will create rpackage folder)
  3. Create new project in RStudio (Create project from: Existing directory) and choose rpackage directory
  4. In RStudio go to Tools/Shell... and type git init
  5. Reopen the project (this will refresh the Git tab)
  6. Start Git/More/Shell and type

    git add *

    git commit -m "first commit"

    git remote add origin git@github.com:[username]/rpackage.git

    git push -u origin master

Then you can refresh repository on github. Now you can close (or even delete) your local project and next time you can start a new project Project/New project/Version Control/Git

You can specify the path to your github repository in create instead of the package name:

create("/path/to/root/of/repository")

Then the normal git commands to add, commit and push to github:

git commit -a -m "initial commit" *
git push

Now there's setup(), which creates the skeleton inside an existing directory. Together with hub, this becomes:

git init NewPackage
cd NewPackage
Rscript -e "devtools::setup()"
hub create
git add .
git commit -m "initial"
git push -u origin HEAD
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!