In modern neuroscience research, collaboration and version control are essential. Whether you're analyzing complex brain imaging data or running computational models, you need efficient tools to manage your code, document your progress, and collaborate seamlessly with colleagues. Visual Studio Code (VS Code) is a powerful code editor that integrates well with Git, the world’s most popular version control system, and with GitHub, a platform for hosting and sharing code repositories.
In this exercise, you’ll learn some basic Git and GitHub workflows using VS Code—skills you can directly apply to a real-world neuroscience project.
- Open Visual Studio Code.
- From the File menu, select Open Folder... (or Open... on some systems).
- Choose a new or empty folder where you’ll store your project files.
Short Description: We’re setting up a dedicated space on your computer to keep all project files organized and ready for version control.
- In the Explorer sidebar (the left panel in VS Code), click New File.
- Name the file
README.md
.
Short Description: The README.md
file is where you’ll describe the purpose, usage, and any other relevant information about your project. Markdown (.md
) files allow you to format text easily.
- Open
README.md
. - Add a short description of your hypothetical data analysis project. For example:
# Neuroscience Data Analysis Project
This project aims to analyze and visualize brain imaging data to identify patterns in neural activity.
- Save the file (
File > Save
or Ctrl+S / Cmd+S).
Short Description: Giving a clear explanation of the project’s purpose can help other researchers quickly understand its goals and scope.
- Open the Source Control panel in VS Code by clicking the Git icon (or press Ctrl+Shift+G / Cmd+Shift+G).
- If your folder isn’t yet a Git repository, you will see an option to Initialize Repository. Click it.
Short Description: Initializing a local repo will allow you to track changes over time, roll back when needed, and collaborate with peers.
- In the Source Control panel, you should see
README.md
as a change. - Click the + icon next to
README.md
to stage it (or use the “Stage All Changes” option). - In the commit message box, type a brief message (e.g.,
Add initial README.md
) and press Enter to commit.
Short Description: Staging files tells Git exactly which changes you want to include in your next snapshot (commit). Committing records those changes in the repo’s history.
- Go to GitHub.com and create a new personal repository. Name it (e.g.,
neuroscience-data-analysis
). - Copy the repository’s URL (usually looks like
https://github.com/YourUserName/neuroscience-data-analysis.git
). - In VS Code, open the Source Control panel, click the three dots (menu), and select Push to.... If prompted to choose a remote, select
origin
or Add Remote and paste the GitHub URL. - After completing these steps, you should be able to push your local commits to GitHub.
Short Description: Pushing your code to GitHub stores it in a remote repository, enabling easy sharing and collaboration.
- On GitHub, navigate to your partner’s repository.
- Click the Fork button in the upper-right corner.
- This creates a personal copy of their repository under your GitHub account.
Short Description: Forking is a way to create your own copy of someone else’s repository, allowing you to propose changes without directly modifying their work.
- From your newly forked repository, click the Code button to copy the URL.
- In VS Code, Clone Git Repository (using the Source Control panel or the Command Palette: Ctrl+Shift+P / Cmd+Shift+P → “Git: Clone”).
- Paste the repository URL and choose a local folder for the clone.
- Open the cloned folder in VS Code.
Short Description: Cloning means downloading the repository (and its entire version history) to your local machine so you can work on it.
- Open the
README.md
file in your local forked repository. - Add a new section, like:
## Contributors - Your Name
- Save the file.
Short Description: A Contributors section acknowledges people who have worked on the project, making it clear who did what.
- Stage your changes in the Source Control panel by clicking the + next to
README.md
. - Write a commit message like
Add my name to Contributors section
. - Click the checkmark or press Enter to commit.
- Push your changes to your fork on GitHub.
Short Description: Always write meaningful commit messages that clearly describe the changes you are making.
- Go to your forked repository on GitHub.
- Click Compare & pull request.
- Review the changes, make sure the base repository is your partner’s original repo, and the head repository is your fork.
- Provide a descriptive title and message, then click Create pull request.
Short Description: A pull request notifies the original repository owner that you have proposed changes. They can review and merge your contributions into their project.
By completing this exercise, you’ve practiced the essential steps for using VS Code, Git, and GitHub in a collaborative research environment—exactly what you’d do in a real neuroscience data analysis project. You learned how to:
- Initialize a local Git repository and create a
README.md
. - Commit and push changes to a remote GitHub repository.
- Fork a partner’s repository, clone it locally, and contribute updates via a pull request.
This workflow keeps everyone on the same page and the project history well-documented. Happy coding and collaborating!