Version control
Version control is a critical practice for managing changes to code, documents, or projects over time. It allows developers to track every modification, collaborate with others, and revert to previous versions if needed. It enable teams to work on the same project without overwriting each other’s changes, resolve conflicts, and maintain a clear history of development. By using version control, you can:
Track changes systematically, making it easy to understand who made what change and when.
Branch and merge code, enabling parallel development (e.g., experimenting with new features without disrupting the main project).
Revert to earlier versions if a bug is introduced or a feature fails.
Collaborate seamlessly with teammates, ensuring everyone works on a consistent, up-to-date codebase.
Common tools/systems¶
Git¶
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Install Git from https://
Basic terminologies¶
Repostory - A repository (or repo) is a storage location for all the files, code, and history of a project. It can be local (on your computer) or remote (on a server like GitHub or GitLab).
Branch - A branch is a separate line of development. It allows you to work on new features, fix bugs, or experiment without affecting the main code (e.g., the
mainormasterbranch).Merge - Merging is the process of combining changes from one branch into another. For example, you might merge a feature branch into the
mainbranch to integrate new code.Clone - Cloning is creating a copy of a remote repository on your local machine. This allows you to work on the project locally and sync changes back to the remote server.
Fork - A fork is a copy of a remote repository (e.g., on GitHub) that belongs to your account. It’s commonly used for contributing to open-source projects or making changes without affecting the original repository.
Commit - A commit is a snapshot of changes made to the files in a repository. Each commit has a message that describes what was changed. Commits are atomic (they capture changes in one logical unit).
Push - Pushing sends your local changes (commits) to a remote repository (e.g., GitHub). This is how you share your work with others or update a remote server.
Pull Request (PR) - A pull request is a proposal to merge your changes (from a branch) into another branch (e.g.,
main). It allows collaborators to review your code, suggest changes, and approve the merge.
Usage¶
After installing Git, you need to configure your username and email address.
git config --global user.name "Your Name"
git config --global user.email "Your Email"You can run the following command to check your configuration.
git config --global --listTo create a new Git repository (assuming you are already inside the project folder):
git initTo add files to the staging area:
git add .To commit the changes:
git commit -m "Initial commit"To push the changes to a remote repository (master branch):
git push origin masterTo pull changes from a remote repository (current branch):
git pullTo clone a remote repository:
git clone <REPOSITORY_URL>To create a new branch:
git checkout -b <NEW_BRANCH>To switch to an existing branch:
git checkout <EXISTING_BRANCH>Git-based platforms/systems¶
GitHub
GitLab
Codeberg
non-profit, community-led effort that provides Git hosting and other services
Gitea
self-hosted devops platform
Forgejo
self-hosted lightweight software forge forked from Gitea