usethis for package development - stuck at Github

Working on first package ever.
Using the usethis workflow as described by Emil Hvitfelt

Project seems ok.
R> proj_sitrep()

  • working_directory: '/Users/peterhiggins/Documents/Rcode/medicaldata'
  • active_usethis_proj: '/Users/peterhiggins/Documents/Rcode/medicaldata'
  • active_rstudio_proj: '/Users/peterhiggins/Documents/Rcode/medicaldata'

stuck on GitHub connection
I have an account with repos, I have a PAT.
R> git_sitrep()
Git user

  • Name: 'Peter Higgins'
  • Email: ''
  • Vaccinated: TRUE
    usethis + git2r
  • Default usethis protocol: 'https'
  • git2r supports SSH: FALSE
  • Credentials: '<usethis + git2r default behaviour>'
  • Personal access token: ''
  • User: 'higgi13425'
  • Name: 'Peter Higgins'
  • Path: '/Users/peterhiggins/Documents/Rcode/.git'
  • Local branch -> remote tracking branch: '' -> ''
    GitHub pull request readiness
    :information_source: This repo has neither 'origin' nor 'upstream' remote on


R> use_github()
:heavy_check_mark: Checking that current branch is 'master'
Error: Detached head; can't continue

Not sure how to get past this problem.

Ideas welcome.
and any explanation of how I borked this also welcome.


Hello all, same case here. Not sure how to go on after this issue.

1 Like

I think you have to stage and commit files first to create the HEAD (or something), then you should be able to use use_github() to initialise the remote.


I think @francisbarton is right. You appear to have initialized a Git repository, but haven't created the first commit. I can recreate the error by running git2r::init() before running usethis::use_github().

If there is no Git repository:

> use_github()
āœ” Setting active project to 'C:/Users/BLISCJX/Documents/test'
Error: Cannot detect that project is already a Git repository.
Do you need to run `use_git()`?

If you initialize the Git repository, but don't create the first commit:

> r <- git2r::init()
> use_github()
āœ” Checking that current branch is 'master'
Error: Detached head; can't continue

In general, if you run usethis::use_git() first (it initializes the repository and also creates a first commit), then you can use usethis::use_github() afterwards.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.