title: using git and curl command line
body: <p>I'm trying to write a function to push a project to github without first creating the project in the clouds.  Currently you can do this from the git command line in RStudio using info from <a href="https://stackoverflow.com/questions/14912161/repo-from-rstudio-to-github">this question</a>.</p>
  
  <p>Now I'm trying to wrap it up into a function that I can use <code>system</code> to create the repo in the clouds from a local repo.  I am working through this on a Windows and linux machine (so not sure how well this works on mac yet).  Here's my code thus far (detect git location):</p>
  
  <pre><code>gitpath &lt;- NULL
      repo &lt;- "New"
      user &lt;- "CantPostThat"
      password &lt;- "blargcats"
  
  
  if (Sys.info()["sysname"] != "Windows") {
      gitpath &lt;- "git"
  } else {
      if (is.null(gitpath)){  
          test &lt;- c(file.exists("C:\\Program Files (x86)\\Git\\bin\\git.exe"),
              file.exists("C:\\Program Files\\Git\\bin\\git.exe"))
          if (sum(test) == 0) {
              stop("Git not found.  Supply path to 'gitpath'")    
          }
          gitpath &lt;- c("\"C:\\Program Files (x86)\\Git\\bin\\git\"",
              "\"C:\\Program Files\\Git\\bin\\git\"")[test][1]
      }
  }
  </code></pre>
  
  <p>I then try it with <code>system</code>:</p>
  
  <pre><code>system(paste(gitpath, "--version"))
  
  &gt; system(paste(gitpath, "--version"))
  git version 1.7.11.msysgit.1
  </code></pre>
  
  <p>Looks good.  But then I try it on a real code chunk:</p>
  
  <pre><code>cmd1 &lt;- paste(gitpath, paste0("curl -u '", user, ":", password, 
      "' https://api.github.com/user/repos -d '{\"name\":\"", repo, "\"}'"))
  
  system(cmd1)
  </code></pre>
  
  <p>And get the message:</p>
  
  <pre><code>&gt; system(cmd1)
  git: 'curl' is not a git command. See 'git --help'.
  
  Did you mean this?
      pull
  Warning message:
  running command '"C:\Program Files (x86)\Git\bin\git" curl -u ' trinker : PASSWORD ' https://api.github.com/user/repos -d '{"name":" three "}'' had status 1 
  </code></pre>
  
  <p>How can I run this command:</p>
  
  <p><code>curl -u 'USER:PASS' https://api.github.com/user/repos -d '{"name":"REPO"}'</code>
  from the console.</p>
  
  <p>I also tried running without putting git in front first.  I'm currently on a win 7 machine</p>