Research Cyberinfrastructure at UW-Madison
Research Cyberinfrastructure Division of Information Technology  ·  UW–Madison

Cloning a GitLab Repository into your BadgerCompute RStudio Session

data-science
r
linguistics
pottery
aikido
brug
personal
reproducibility
productivity
coding
A short tutorial that teaches how to bring your code from a GitLab repo into a BadgerCompute session
Author
Affiliation

Erwin Lares

Research Cyberinfrastructure (RCI), Division of Information Technology, UW-Madison

Published

July 2, 2026

Modified

July 2, 2026

Abstract
This guide documents the steps to clone a private repository from UW-Madison’s GitLab instance (git.doit.wisc.edu) into an RStudio Server session on BadgerCompute. The approach uses HTTPS with a Personal Access Token (PAT). SSH is not practical here because files outside ~/work are wiped on session reset, meaning SSH keys stored in ~/.ssh would be lost each time.
NotePrerequisites
  • An active BadgerCompute session at launch.badgercompute.wisc.edu
  • A UW NetID with Reporter-level access or higher on the target GitLab project
  • A Personal Access Token generated from your user profile at
    https://git.doit.wisc.edu/-/user_settings/personal_access_tokens
    • read_repository scope — required for cloning
    • write_repository scope — required if you intend to push changes
  • A Terminal open in RStudio Server: Tools → Terminal → New Terminal

1 Step 1: Navigate to Persistent Storage

All work must be kept inside ~/work — it is the only directory that persists across BadgerCompute session resets.

cd ~/work

Your prompt should now show ~/work as the current directory.


2 Step 2: Verify git is Available

which git
git --version

You should see a path like /usr/bin/git and a version string such as git version 2.x.x. Git is pre-installed in the BadgerCompute environment.


3 Step 3: Configure git Identity

WarningThis setting does not persist across sessions

~/.gitconfig lives outside ~/work and is deleted on session reset. You will need to re-run these lines at the start of each new BadgerCompute session. See the Session Reset section for a setup script that automates this.

Set the name and email that will be attached to your commits:

git config --global user.name "Your Name"
git config --global user.email "netid@wisc.edu"

4 Step 4: Set Up Persistent Credential Storage

By default, git stores credentials in ~/.git-credentials, which is outside ~/work and wiped on reset. Anchor it to ~/work with a symlink so your token survives session resets:

touch ~/work/.git-credentials
ln -s ~/work/.git-credentials ~/.git-credentials
git config --global credential.helper store

Verify the symlink is in place:

ls -la ~/.git-credentials
# Expected output:
# lrwxrwxrwx ... /home/jovyan/.git-credentials -> work/.git-credentials
Note

If you have run this before, ln will report that the symlink already exists — that is expected and means your credentials are already persisted. No action needed.


5 Step 5: Clone the Repository

git clone https://git.doit.wisc.edu/<group>/<project>.git

When prompted:

  • Username: your NetID (e.g. lares)
  • Password: your Personal Access Token
WarningTreat your PAT like a password

Never paste your Personal Access Token into a shared script or commit it to a repository. It grants access to your GitLab account and should be kept private.

After a successful clone, credentials are written to ~/work/.git-credentials automatically. Subsequent git pull and git push commands will not prompt again.

ImportantGetting a 403 error?

A 403 “not allowed to download code” error means one of:

  1. Wrong token type — you may have generated a Project Access Token (a bot account) instead of a Personal Access Token. Verify by running:

    curl -H "PRIVATE-TOKEN: <your-token>" https://git.doit.wisc.edu/api/v4/user

    The response should show your own NetID and "bot": false. If you see "bot": true, generate a new token from your user profile instead of the project settings.

  2. Insufficient access level — Guest access (level 10) cannot clone. You need Reporter (level 20) or higher. Ask the project owner to update your role at:
    https://git.doit.wisc.edu/<group>/<project>/-/project_members


6 Step 6: Verify the Clone and Remote

cd <project-name>
git remote -v

Expected output:

origin  https://git.doit.wisc.edu/<group>/<project>.git (fetch)
origin  https://git.doit.wisc.edu/<group>/<project>.git (push)

7 Step 7: Open the Project in RStudio

With the repository cloned, open it as an RStudio Project:

File → Open Project → navigate to ~/work/<project-name>

If the repo contains an .Rproj file, open that directly. Otherwise create a new project in the cloned directory:

File → New Project → Existing Directory → select ~/work/<project-name>

The Git pane will appear in the upper-right panel (alongside Environment and History), giving you point-and-click access to pull, commit, push, and diff without leaving RStudio.

Tip

If the Git pane does not appear after opening the project, try restarting RStudio within the session: Session → Restart R.


8 Handling Session Resets

BadgerCompute sessions shut down after 4 hours or 10 minutes of inactivity. On reset, ~/.gitconfig is deleted but ~/work/.git-credentials survives.

Save the following script once to ~/work/setup-git.sh to restore your config quickly at the start of each session:

#!/bin/bash
# ~/work/setup-git.sh
# Run at the start of each BadgerCompute session.

git config --global user.name "Your Name"
git config --global user.email "netid@wisc.edu"
git config --global credential.helper store

# Restore symlink if missing
if [ ! -L ~/.git-credentials ]; then
  touch ~/work/.git-credentials
  ln -s ~/work/.git-credentials ~/.git-credentials
  echo "Credentials symlink restored."
else
  echo "Credentials symlink already in place."
fi

echo "git config restored."

Make it executable once:

chmod +x ~/work/setup-git.sh

Run it at the start of each new session:

bash ~/work/setup-git.sh

Or from the RStudio R console:

system("bash ~/work/setup-git.sh")

9 Quick Reference

Task Command
Verify git git --version
Set identity git config --global user.name "Name"
Set email git config --global user.email "netid@wisc.edu"
Enable credential store git config --global credential.helper store
Check symlink ls -la ~/.git-credentials
Clone repo git clone https://git.doit.wisc.edu/<group>/<project>.git
Verify remote git remote -v
Restore session config bash ~/work/setup-git.sh

10 See Also