git clone is a general way to check out a local copy of any git repository. It doesn't know about R at all or how R packages work. The devtools::install_github() (which is really just remotes::install_github()) checks out a copy of a repository and then does the extra work of actually building and installing the package so R can use it. Also it removes the local copy of the raw source files after it installs. If you just want to run/use the package, use remotes::install_github(). If you want to edit/contribute to the source code for a package, then use git clone to get the code.

Answer from MrFlick on Stack Overflow
🌐
GitHub
github.com › r-lib › devtools
GitHub - r-lib/devtools: Tools to make an R developer's life easier · GitHub
Generally, you would not need to worry about these different packages, because devtools installs all of them automatically.
🌐
RDocumentation
rdocumentation.org › packages › devtools › versions › 1.13.6 › topics › install_github
install_github function - RDocumentation
devtools (version 1.13.6) This function is vectorised on repo so you can install multiple packages in a single command. install_github(repo, username = NULL, ref = "master", subdir = NULL, auth_token = github_pat(quiet), host = "https://api.github.com", quiet = FALSE, ...) repo ·
People also ask

Do I need to install devtools every time?
No—install it once. In future sessions either run library(devtools) or use the prefix devtools::install_github().
🌐
displayr.com
displayr.com › home › blog › how to install r packages from github (step-by-step guide)
How to Install R Packages from GitHub (Step-by-Step Guide)
Why is install_github() failing?
Common causes: devtools/remotes not installed/loaded, missing build tools (Rtools on Windows, Xcode CLT on macOS), typo in user/repo, private repo/auth issues, or network/proxy restrictions.
🌐
displayr.com
displayr.com › home › blog › how to install r packages from github (step-by-step guide)
How to Install R Packages from GitHub (Step-by-Step Guide)
How do I update a package installed from GitHub?
Re-run install_github("user/repo") to get the latest, or use remotes::update_packages().
🌐
displayr.com
displayr.com › home › blog › how to install r packages from github (step-by-step guide)
How to Install R Packages from GitHub (Step-by-Step Guide)
🌐
Displayr
displayr.com › home › blog › how to install r packages from github (step-by-step guide)
How to Install R Packages from GitHub (Step-by-Step Guide)
September 17, 2025 - 1. How do I install an R package from GitHub in RStudio? Open the Console and run the same commands as in base R: install.packages("devtools") devtools::install_github("user/repo")
Top answer
1 of 2
5

git clone is a general way to check out a local copy of any git repository. It doesn't know about R at all or how R packages work. The devtools::install_github() (which is really just remotes::install_github()) checks out a copy of a repository and then does the extra work of actually building and installing the package so R can use it. Also it removes the local copy of the raw source files after it installs. If you just want to run/use the package, use remotes::install_github(). If you want to edit/contribute to the source code for a package, then use git clone to get the code.

2 of 2
2

devtools::install_github is an R function that attempts to install a package directly from GitHub repositories (Link to Documentation). This allows to install packages automatically from GitHub. You can specify multiple repositories in a single call to the function like this (Example from the previous link that attempts to install multiple repositories):

install_github(c("rstudio/httpuv", "rstudio/shiny"))

git clone is a console command that clones a git repository, by copying all the files (Link to Documentation). You only can clone one repository by command, and you may need to build and install the package after cloning it. Also, you can clone from hosts different to GitHub, like BitBucket, GitLab, or a custom git server. You can clone a repository like this (Example from the previous link that attempts to clone a repository from a host different to GitHub):

git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
🌐
Kbroman
kbroman.org › pkg_primer › pages › github.html
Putting your R package on GitHub
Load the devtools package. ... In most cases, you just use install_github("author/package").
🌐
GitHub
github.com › the-dev-tools › dev-tools
GitHub - the-dev-tools/dev-tools: Local-first API workflows that go from HAR file to GitHub Actions in 60 seconds. · GitHub
Installation · Chrome Extension · Contributing · License · DevTools gives developers complete control over their API testing workflows: Browser Request Recording: Automatically capture all API requests and responses from your browser sessions. No-code Test Generation: Transform your recorded API requests into reusable test collections.
Author: the-dev-tools
🌐
GitHub
github.com › samuelcolvin › python-devtools
GitHub - samuelcolvin/python-devtools: Dev tools for python · GitHub
If you've got python 3.10+ and pip installed, you're good to go. from devtools import debug whatever = [1, 2, 3] debug(whatever)
Find elsewhere
Top answer
1 of 2
47

You need to append tags for releases directly onto the name of the repository argument. So, username/repo@releasetag will work. Only use the parameter ref = "devA" when you need to refer to a specific branch of the git repository.

For your example, regarding OhdsiRTools v1.0.1, we have

we have:

devtools::install_github("OHDSI/OhdsiRTools@v1.0.1")

Edit

After toying around with devtools source, it has come to my attention that one can request the latest source with:

username/repo@*release

Hence, you could use:

devtools::install_github("OHDSI/OhdsiRTools@*release")

End Edit

Outdated, see edit

Unfortunately, to obtain the latest release tag, the work for that is a bit more complicated as it would involve parsing a response from the GitHub API. Here are some notes if you really do need the tagged version... You would have to parse JSON from:

https://api.github.com/repos/<user>/<repo>/releases/latest

using either RJSONIO, jsonlite, rjson

To extract "tag_name" from:

{
  "url": "https://api.github.com/repos/OHDSI/OhdsiRTools/releases/2144150",
  "assets_url": "https://api.github.com/repos/OHDSI/OhdsiRTools/releases/2144150/assets",
  "upload_url": "https://uploads.github.com/repos/OHDSI/OhdsiRTools/releases/2144150/assets{?name,label}",
  "html_url": "https://github.com/OHDSI/OhdsiRTools/releases/tag/v1.0.1",
  "id": 2144150,
  "tag_name": "v1.0.1",
  "target_commitish": "master",
  "name": "Minor bug fix",
  "draft": false,
  "author": {
    "login": "schuemie",
    "id": 6713328,
    "avatar_url": "https://avatars.githubusercontent.com/u/6713328?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/schuemie",
    "html_url": "https://github.com/schuemie",
    "followers_url": "https://api.github.com/users/schuemie/followers",
    "following_url": "https://api.github.com/users/schuemie/following{/other_user}",
    "gists_url": "https://api.github.com/users/schuemie/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/schuemie/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/schuemie/subscriptions",
    "organizations_url": "https://api.github.com/users/schuemie/orgs",
    "repos_url": "https://api.github.com/users/schuemie/repos",
    "events_url": "https://api.github.com/users/schuemie/events{/privacy}",
    "received_events_url": "https://api.github.com/users/schuemie/received_events",
    "type": "User",
    "site_admin": false
  },
  "prerelease": false,
  "created_at": "2015-11-18T00:55:28Z",
  "published_at": "2015-11-18T06:35:57Z",
  "assets": [

  ],
  "tarball_url": "https://api.github.com/repos/OHDSI/OhdsiRTools/tarball/v1.0.1",
  "zipball_url": "https://api.github.com/repos/OHDSI/OhdsiRTools/zipball/v1.0.1",
  "body": "Fixed bug in `convertArgsToList ` function."
}

Above is taken from https://api.github.com/repos/OHDSI/OhdsiRTools/releases/latest

2 of 2
42

For anyone who arrives here looking for how to install from a specific commit SHA, it's simply:

remotes::install_github("username/repository@commitSHA")

Example

Look for the SHA for the commit you want to install from the 'commits' page on github:

In this case the commit SHA is: 8bc79ec6dd57f46f753cc073a3a50e0921825260, so simply:

remotes::install_github("wilkelab/ggtext@8bc79ec6dd57f46f753cc073a3a50e0921825260")
🌐
GitHub
github.com › me-shaon › devtools
GitHub - me-shaon/devtools: Ultimate developers toolkit desktop app · GitHub
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev \ libxdo-dev libssl-dev patchelf file rpm · git clone https://github.com/me-shaon/devtools.git cd devtools npm ci npm run dev
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-r-packages-using-devtools-on-ubuntu-18-04
How to Install R Packages using devtools on Ubuntu 18.04 | DigitalOcean
July 16, 2018 - In this step, we’re going to install the latest development build of Shiny, a web application framework for R, directly from GitHub. We’ll do this using the install_github function provided by devtools.
🌐
GitHub
github.com › alexvenzke › devtools
GitHub - alexvenzke/devtools: Ultimate developers toolkit desktop app · GitHub
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev \ libxdo-dev libssl-dev patchelf file rpm · git clone https://github.com/me-shaon/devtools.git cd devtools npm ci npm run dev
Top answer
1 of 3
55

To add specified library paths in devtools, we need to use with_libpaths()

Arguments for with_libpaths() are, with_libpaths(new, code)

Following is an example for using with_libpaths(),

library(devtools)
with_libpaths(new = "/usr/lib/R/site-library/", install_github('rCharts', 'ramnathv'))

Courtesy: Hadley, here :)

And other than with_libpaths(), there are more options for in devtools::with_something()

in_dir: working directory
with_collate: collation order
with_envvar: environmental variables
with_libpaths: library paths, replacing current libpaths
with_lib: library paths, prepending to current libpaths
with_locale: any locale setting
with_options: options
with_path: PATH environment variable
with_par: graphics parameters

More explanations here

2 of 3
14

install_github takes a ... argument that passes to devtools::install. devtools::install has an args argument.

args
An optional character vector of additional command line arguments to be passed to R CMD install. This defaults to the value of the option "devtools.install.args".

R CMD install takes a library argument

 Options:
  -h, --help            print short help message and exit
  -v, --version         print INSTALL version info and exit
  -c, --clean           remove files created during installation
      --preclean        remove files created during a previous run
  -d, --debug           turn on debugging messages
                        and build a debug DLL
  -l, --library=LIB     install packages to library tree LIB

So the following should work:

devtools::install_github("repo", args = c('--library="./mypath/gdfgdg/"'))

however it doesnt appear to be replacing the call to R CMD install

"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" --vanilla CMD INSTALL  \
  "C:\Users\john\AppData\Local\Temp\RtmpucrXMD/RSelenium_1.3.2.tar.gz"  \
  --library="C:/Users/john/Documents/R/win-library/3.1" --install-tests  \
  --library="C:/Users/john/Desktop/"
🌐
Johnmuschelli
johnmuschelli.com › neuroc › installing_devtools › index.html
Installing devtools - John Muschelli
February 16, 2021 - So if you want to install a package from GitHub, but not update any of the dependencies, then you can use install_github(..., upgrade_dependencies = FALSE). If you cannot install devtools, many times it is due to git2r.
🌐
CRAN
cran.r-project.org › web › packages › devtools › readme › README.html
README - devtools
You may also need to care if you are trying to use some devtools functionality in your own package or deployed application. Generally in these cases it is better to depend on the particular package directly rather than depend on devtools, e.g. use sessioninfo::session_info() rather than devtools::session_info(), or pak::pak("user/repo") vs devtools::install_github("user/repo").
🌐
Stack Overflow
stackoverflow.com › questions › 76915654 › why-use-devtoolsinstall-github-instead-of-remotesinstall-github
r - Why use `devtools::install_github` instead of `remotes::install_github`? - Stack Overflow
The recommendations in "R Packages (2e)" by Hadley Wickham and Jennifer Bryan leave you with the following installation recommendation in your README file: # install.packages("devtools&
🌐
GitHub
gist.github.com › dlerm › c9bd9eaab46a3024481eb803477f4ed2
Dev tools install script · GitHub
Dev tools install script. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › tafuru › devtools
GitHub - tafuru/devtools: Install GUI apps and fonts for macOS and Ubuntu/Debian. · GitHub
Use dev-setup --devtools if you want this layer as part of the full machine bootstrap. Run this repository directly if your CLI tools and dotfiles are already in place. ... On macOS, apps and fonts are installed through Homebrew Cask. On Ubuntu/Debian, apps are installed from vendor-supported sources where practical, and HackGen Nerd Font is installed from GitHub Releases.
🌐
DevTools
dev.tools › docs › start-here › install
Getting Started with DevTools – DevTools
Yes, DevTools is open source under the Apache-2.0 license and free to use. The source code is available on GitHub (opens in a new tab).
🌐
vembedr
ijlyttle.github.io › nondim_devtools_gh.html
Devtools and GitHub Enterprise
As you know, the devtools package makes it super-easier to develop and deploy packages. Thanks to Hadley Wickham, installing a package from GitHub is as easy as devtools::install_github(); thanks to Jenny Bryan, starting your own package using GitHub as simply a call to devtools::use_github().