Skip to content
Lionel Henry edited this page Oct 30, 2018 · 22 revisions

Setup instructions

Cloning this repository is the same as with any other git repository.

git clone https://github.com/wch/r-source.git
cd r-source

To clone the repository without fetching the entire history of the project, you can do a shallow clone, with:

# Get just the last commit
git clone https://github.com/wch/r-source.git --depth 1

Shallow clones are quick, but it is often useful to clone the full history locally. This allows you to search the history, blame, etc.

These are some useful commands on your local clone of the repository:

git branch -a                     # Show all branches (including remote branches)
git checkout origin/R-2-15-branch # Checkout a branch
git checkout origin/tags/R-2-15-1 # Checkout a tag (this is how svn tags are represented)
git checkout trunk                # 'trunk' is the only local branch; it tracks origin/trunk

Initialising git-svn

R can't be built from a bare git repository because it needs SVN information. You'll need to transform the fresh git clone into a proper git-svn repository. Because you have cloned from wch/r-source, the following command automatically sets your repo to track that remote for new SVN revisions:

# Prefix should match remote repo name with a trailing slash
git svn init --prefix=origin/ -s https://svn.r-project.org/R/

To our knowledge, there is no reliable way to recover the full history of a shallow clone once you've initialised git-svn. So be sure to run git pull --unshallow before git svn init if you'd like to work with the full history (recommended).

Git-SVN repositories work a little differently than normal git repos because SVN has no support for non-linear history. To work around this, git-svn commands avoid any pulling or merging. The main command to know about is git svn rebase which fetches from wch new revisions for the current branch (typically trunk), and rebase any unpushed commits on top of it. In normal workflows, we don't have any unpushed commits on trunk, so the net effect of rebasing is to set our local trunk branch to point to the latest revisions fetched from wch:

git svn rebase

Check that git-svn is correctly initialised:

git svn info

Rebasing automatically fetches revisions for the current branch, which you can do manually with:

git svn fetch --parent

To fetch for all branches, remove --parent. The first time will take a long time because it needs to build the mappings from SVN revisions to git SHA-1's for all SVN branches and tags. Also, this command fetches all unfetched branches and thus will take an even longer time if you've cloned with --depth=1 (unless you've also passed --no-single-branch to git clone):

git svn fetch

Important: Once you've initialised git-svn, never use git pull again, or you will cause trouble to your repo. Always use git svn rebase. If you see "Unable to determine upstream SVN information from working tree history", that's probably because you've used git pull.

Building R from source

Here is the minimal procedure for building an R:

# Download recommended packages
tools/rsync-recommended

./configure && make all && make install

However, building in the repo root is not optimal because all the build files (autotools files, compiled object files, test artifacts, ...) are created in place and end up cluttering the working directory. It is recommended to create all build artifacts in a separate directory. To do so, just call the configure script from that location. Here we're going to create a build directory inside the repository and gitignore it, but it could just as well be located outside the repo:

mkdir build
echo "build/" >> .git/info/exclude

cd build
../configure && make all && make install

Build instructions for specific platforms

Contributing patches to R core

See Contributing.

Other mirrors

There is another r-source repository on GitHub, which has one commit per R release. This can be useful if you're just interested in seeing the changes between versions: https://github.com/SurajGupta/r-source

Clone this wiki locally