Set up a GitHub Repository

Configure .gitignore

Initializing a Git repository may encounter an error/warning if an renv or venv is already established. This is because these directories can containe thousands of files. To avoid this warning, create a .gitignore file specifying the directories and files to exclude from tracking before initializing a Git directory.

/py_env # excludes the py_env directory
/renv

*.html  # excludes all .html files
*.yml   # excludes all .yml files
*.ipynb # excludes all .ipynb files

Version 1: Set up a repo on GitHub.com first

  1. Install Git if not done already
  2. Create a new project folder.
  3. Create a new repository on GitHub.com. Set the name, privacy level, description (optional), and then the green “Create repository” button.
  4. Do not navigate aways from the page as the commands listed there will be needed to configure the repository locally.
  5. Copy the first 4 lines.
echo "# repository name" >> README.md
git init
git add README.md
git commit -m "first commit"
  1. Open a terminal window (Powershell, bash, etc.) and navigate to the project’s root directory.

  2. From the root directory paste and execute the each command.

  3. Execute the following two commands with replacing the desired GitHub or Organization’s user name and email.

git config --local user.name ["GitHub/Org's user name"]
git config --local user.email ["GitHub/Orgs's email"]
  1. Enter the remaining commands from the GitHub web page in steps 3-4.
git branch -M main
git remote add origin https://github.com/[User/Org_name]/[repository-name].git
git push -u origin main

To test your repository, open the README.md file using VS Code and make some minor modifications and save it. Then click on the Source Control icon from the left hand side of the application. Use the plus “+” symbol to stage the file. Then add Message in the field. Then click on the Commit button. Finally you can click the Sync button to push the changes back to GitHub.