I once asked a very similar question and got a response that worked from the command line but am now wanting to use R to automate the process from Windows (Linux is much easier).
Here is what I'm trying to do:
- Create a local directory (or it exists already)
- Generate a new github repo in the cloud by the same name as local (based on this answer)
- Add a .git to the local repo
- Make an initial commit
- Establish link between cloud repo and local repo
- Push the commit and the files in the local repo to github
I believe based on the output that I get all the way to step 5 before I fail (as the commit and files from the local directory never go to github in the cloud).  I know step 2 works because the empty repo is created here.  I don't know how to test step 5.  At the last step shell(cmd6, intern = T) RGui and RStudio result in an eternal death spiral.  The question is: How can I push the commit and local repo to the cloud. 
Here is my updated code (the only thing that is user specific is username and password in third code chunk):
## Create Directory
repo <- "foo5"
dir.create(repo)
project.dir <- file.path(getwd(), repo) 
## Throw a READ.ME in the directory
cat("This is a test", file=file.path(project.dir, "READ.ME"))
## Github info (this will change per user)
password <-"pass" 
github.user <- "trinker"  
## Get git location
test <- c(file.exists("C:/Program Files (x86)/Git/bin/git.exe"),
    file.exists("C:/Program Files/Git/bin/git.exe"))
gitpath <- c("C:/Program Files (x86)/Git/bin/git.exe",
  "C:/Program Files/Git/bin/git.exe")[test][1]
## download curl and set up github api
wincurl <- "http://curl.askapache.com/download/curl-7.32.0-win64-ssl-sspi.zip"
url <- wincurl
tmp <- tempfile( fileext = ".zip" )
download.file(url,tmp)
unzip(tmp, exdir = tempdir())       
shell(paste0(tempdir(), "/curl http://curl.haxx.se/ca/cacert.pem -o " , 
    tempdir() , "/curl-ca-bundle.crt"))
json <- paste0(" { \"name\":\"" , repo , "\" } ") #string we desire formatting
json <- shQuote(json , type = "cmd" )
cmd1 <- paste0( tempdir() ,"/curl -i -u \"" , github.user , ":" , password , 
    "\" https://api.github.com/user/repos -d " , json )
shell(cmd1, intern = T)
## Change working directory
wd <- getwd()
setwd(project.dir)
## set up the .git directory
cmd2 <- paste0(shQuote(gitpath), " init")
shell(cmd2, intern = T)
## add all the contents of the directory for tracking
cmd3 <- paste0(shQuote(gitpath), " add .")  
shell(cmd3, intern = T)       
cmdStat <- paste0(shQuote(gitpath), " status")  
shell(cmdStat, intern = T)
## Set email (may not be needed)
Trim <- function (x) gsub("^\\s+|\\s+$", "", x) #remove trailing/leading white 
x <- file.path(path.expand("~"), ".gitconfig")
if (file.exists(x)) {
    y <- readLines(x)
    email <- Trim(unlist(strsplit(y[grepl("email = ", y)], "email ="))[2])
} else {
    z <- file.path(Sys.getenv("HOME"), ".gitconfig")
    if (file.exists(z)) {
        email <- Trim(unlist(strsplit(y[grepl("email = ", y)], "email ="))[2])
    } else {
        warning(paste("Set `email` in", x))
    }
}
cmdEM <- paste0(shQuote(gitpath), sprintf(" config --global user.email %s", email))        
system(cmdEM, intern = T)
## Initial commit
cmd4 <- paste0(shQuote(gitpath), ' commit -m "Initial commit"')  
system(cmd4, intern = T) 
## establish connection between local and remote
cmd5 <- paste0(shQuote(gitpath), " remote add origin https://github.com/",
    github.user, "/", repo, ".git")  
shell(cmd5, intern = T) 
## push local to remote 
cmd6 <- paste0(shQuote(gitpath), " push -u origin master")  
shell(cmd6, intern = T) 
setwd(wd)
I know the script is a bit longer but it's all necessary to recreate the problem and replicate the issue:
Note I updated the question in light of Simon's response as he was correct and got closer to the push. The content of the original question can be found here.
 
     
     
    