rgithubr-usethis

R: usethis: push to Github on an already created repository


I am trying to push to Github on an already created repository. I use usethis to clone a Repo, and now I wanna update and push some new files, lamentably I have some error: Repo already exists, but my goal is push only new files. I tried literally hundreds of times,

I change example:

library(usethis)

create_from_github("site99999/BaseDatos")

v Setting `fork = FALSE`
v Creating 'C:/Users/roro999999/Desktop/BaseDatos/'
v Cloning repo from 'https://github.com/site9999/BaseDatos.git' into 'C:/Users/roro9999999/Desktop/BaseDatos'
v Setting active project to 'C:/Users/roro999999/Desktop/BaseDatos'
i Default branch is 'main'


use_git(message = "Archivos subidos por Rodrigo")

#My goal is push only this 3 new files to my Repo:
There are 3 uncommitted files:
* '.gitignore'
* 'R/'
* 'SQL/'
Is it ok to commit them?

1: Absolutely not
2: Nope
3: For sure

3

use_github(private=T)

Error: This repo already has an 'origin' remote, with value 'https://github.com/site99999/BaseDatos.git'.

#Here I change the origin to my personal repo
use_git_remote("origin", url = NULL, overwrite = T)

#Here I tried to push
use_github(private=T)

Error: Repo 'roro999999/BaseDatos' already exists on 'github.com'

My Github configuration:

* Personal access token for 'https://github.com': '<discovered>'
* GitHub user: 'roro9999999'
* Token scopes: 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages'
* Email(s): 'ro999999999@gmail.com (primary)'
Git repo for current project
* Active usethis project: 'C:/Users/roro999999/Desktop/BaseDatosPMG'
* Default branch: 'main'
* Current local branch -> remote tracking branch:
  'main' -> 'origin/main'
GitHub remote configuration
* Type = 'ours'
* Host = 'https://github.com'
* Config supports a pull request = TRUE
* origin = 'site99999/BaseDatos' (can push)
* upstream = <not configured>
* Desc = 'origin' is both the source and primary repo.

Solution

  • The r-lib/usethis/R/github.R use_github() is there to create the GitHub repository and push local commits to it.

    So try and not create it first, meaning to not start from a clone (which implies an origin, and an existing GitHub repository).