Version Control with Gitο
When working on a project, specially a robotics project, where multiple teams are working on the same code base, it is important to have a way to track and manage those changes. This is where version control comes in.
Version control, also known as, source control, is practice of tracking and managing changes to software code. Version control system keep track of all the changes to source code over time and the user who made those changes. It is like a time machine that help you save all your progress and then if you did something wrong go back to the last working commit and start working from their.
It is also useful for team collaboration, with multiple members working on same piece of code it is easier to manage and merge the changes made by multiple developers. Back to the time machine analogy, think of it as multiple members working at different time and then going back in time and combining their efforts into a single activity.
What is Git?ο
Git is the most widely adopted and stable verison control system thier exists. It is a distributed version control system, which means that every developer has a complete copy of the repository on their local machine, so any change you make to the code is saved locally and needs to be pushed to the remote repository.
Their are also other type of version control system like Subversion (SVN) that are centralized, which means that there is a single central repository and all the developers have to connect to that repository to make changes. SVN requires internet connection to the server to commit changes.
For our purposes we will be using Git as our version control system.
Installing Gitο
Git is free and open source software, so you can download it from the official website. The installation process is different for each operating system.
For Windowsο
Download the latest version of Git for Windows from the official website.
Run the installer and follow the instructions.
During the installation, you can choose the default options or customize them according to your preferences.
For MacOSο
Open the Terminal application.
If Homebrew is not installed, install it by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Git using Homebrew by running the command:
brew install git
Verify the installation by running:
git --version
Git commands summaryο
This is a summary of the most common Git commands. For more detailed information, please refer to the official Git documentation.
Command |
Description |
|---|---|
|
Create an empty Git repository in the specified directory. |
|
Clone an existing repository from a remote URL. |
|
Set the authorβs name for commits (Should match your remote username) |
|
Stage all changes in a directory for the next commit. |
|
Commit staged changes with a message. |
|
Show the status of files (staged, unstaged, untracked). |
|
Display commit history. |
Command |
Description |
|---|---|
|
Create a new commit that undoes the changes of a previous commit. |
|
Unstage a file but keep the working directory unchanged. |
|
Show untracked files to be removed. |
Command |
Description |
|---|---|
|
Modify the most recent commit message. |
|
Rebase the current branch onto another branch or commit. |
|
Show a log of changes to HEAD. |
Command |
Description |
|---|---|
|
List all branches. |
|
Create and switch to a new branch. |
|
Merge another branch into the current branch. |
Command |
Description |
|---|---|
|
Add a new remote repository. |
|
Fetch updates from a remote repository. |
|
Fetch and merge changes from a remote branch. |
|
Push local changes to a remote branch. |
Githubο
Github is a web-based platform that stores and manages Git repositories on the cloud. It is like a google cloud for your code. It allows you to directly push code to the cloud and share it with others. In this tutorial we will be using Github for getting the code and pushing the practice code.
Important
Work in Progress!
This section is a work in progress, and will be updated soon (When I get bored with my current work, or you decide to complete it βοΈ).