Version control with Git
Last updated: June 13, 2025
Version control is a system that records changes to your files over time, allowing you to recall specific versions later. Think of it as a comprehensive history for your entire project. It lets you track who made what changes, revert to previous states if a bug is introduced, and collaborate safely with a team.
Every Codesphere workspace is a fully-featured Git repository, the industry standard for version control, integrated directly into your workflow.
The core Git workflow
The daily development cycle with Git revolves around three key actions: Pulling, Committing, and Pushing.
1. Pulling changes:
Before you start working, it's crucial to ensure you have the latest version of the code from your team. "Pulling" downloads any changes from the central remote repository (e.g., GitHub, GitLab) and updates your local workspace.
Why: To prevent conflicts and ensure you're building upon your team's most recent work.
How: Click the "Pull" button located in the top bar of the IDE. It's best practice to do this every time you start a new work session.
2. Committing changes:
A "commit" is a snapshot of your project at a specific point in time. Instead of just saving a file, you are saving a checkpoint of the entire project that you can always return to.
Why: To create a detailed history of your project's development. Small, frequent commits make it easy to understand how the project evolved and to pinpoint where bugs were introduced.
How:After editing your files, navigate to the Git tab in the sidebar.
You will see a list of all your modified files under "Changes".
In the text box at the top, write a clear commit message describing why you made these changes (e.g., "Feat: Add user authentication endpoint").
Click the "Commit" button to save the snapshot to your workspace's local history.
3. Pushing changes
"Pushing" is how you upload your saved commits from your local workspace to the central remote repository. This makes your work available to the rest of your team.
Why: To share your contributions and back up your work to a central location.
How: After making one or more commits, click the "Push" button in the top bar of the IDE.
Working with branches
A branch is an independent line of development. Branches allow you to work on new features or bug fixes in an isolated environment without affecting the main codebase (often called the main or master branch).
The typical workflow is to create a new branch for each new task. You make all your commits on this feature branch. When the feature is complete and tested, you merge the branch back into the main codebase, often through a Pull Request. You can manage your current branch from the top bar of the IDE, next to the Pull and Push buttons.
By mastering the pull-commit-push cycle and using branches effectively, you can ensure a safe, transparent, and highly collaborative development process.