2

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.

1 Answers1

0

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).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for your comments. Do you know the command that I should use instead use_github, I have look but none succesfull. – Rodrigo Badilla Aug 05 '22 at 12:34
  • @RodrigoBadilla Exactly: looking at the source of this library, there does not seem to be one for just `git push`. You might have to code it directly, taken inspiration from `use_github()`, in order to just push. – VonC Aug 05 '22 at 13:23
  • Thnks. I will try not start from a clone. I tried deleting my repo but I think that the original push focus its different: upload only 3 uncommitted files and not files that already exist . – Rodrigo Badilla Aug 05 '22 at 13:46
  • @RodrigoBadilla If you do try git bash, consider [installing the GitHub CLI `gh`](https://github.com/cli/cli#installation): it will facilitate the creation and import of a GitHub repository. – VonC Aug 05 '22 at 13:47