Lab_git
Lab_git
Objective:
The objective of this experiment is to familiarise participants with essential Git concepts and
commands, enabling them to effectively use Git for version control and collaboration.
Introduction:
Git is a distributed version control system (VCS) that helps developers track changes in their
codebase, collaborate with others, and manage different versions of their projects efficiently.
It was created by Linus Torvalds in 2005 to address the shortcomings of existing version
control systems. Unlike traditional centralised VCS, where all changes are stored on a central
server, Git follows a distributed model. Each developer has a complete copy of the repository
on their local machine, including the entire history of the project. This decentralisation offers
numerous advantages, such as offline work, faster operations, and enhanced collaboration.
Git is a widely used version control system that allows developers to collaborate on projects,
track changes, and manage codebase history efficiently. This experiment aims to provide a
hands-on introduction to Git and explore various fundamental Git commands. Participants
will learn how to set up a Git repository, commit changes, manage branches, and collaborate
with others using Git.
Key Concepts:
Repository: A Git repository is a collection of files, folders, and their historical
versions. It contains all the information about the project's history, branches, and
commits.
Commit: A commit is a snapshot of the changes made to the files in the repository at a
specific point in time. It includes a unique identifier (SHA-1 hash), a message
describing the changes, and a reference to its parent commit(s).
Branch: A branch is a separate line of development within a repository. It allows
developers to work on new features or bug fixes without affecting the main codebase.
Branches can be merged back into the main branch when the changes are ready.
Merge: Merging is the process of combining changes from one branch into another. It
integrates the changes made in a feature branch into the main branch or any other
target branch.
Pull Request: In Git hosting platforms like GitHub, a pull request is a feature that
allows developers to propose changes from one branch to another. It provides a
platform for code review and collaboration before merging.
Remote Repository: A remote repository is a copy of the Git repository stored on a
server, enabling collaboration among multiple developers. It can be hosted on
platforms like GitHub, GitLab, or Bitbucket.
Materials:
Experiment Steps:
git init
Create a new text file named "example.txt" using any text editor.
Add some content to the "example.txt" file.
In the command-line interface, run the following commands:
git status
This command shows the status of your working directory, highlighting untracked
files.
git status
git diff
This displays the differences between the working directory and the last commit.
git log
or shorthand:
Merge the changes from the "feature" branch into the "master" branch:
Conclusion:
Through this experiment, participants gained a foundational understanding of Git's essential
commands and concepts. They learned how to set up a Git repository, manage changes,
explore commit history, create and merge branches, and collaborate with remote repositories.
This knowledge equips them with the skills needed to effectively use Git for version control
and collaborative software development.