L6 - Version Control
L6 - Version Control
Software Engineering
Git and Github
Imran Zahid
Lecturer
Computer Science and Engineering, BRAC University
Git
What is Git?
• A distributed version control system
• A Version Control System (VCS) is software that
manages changes to files, especially source code,
over time.
• Distributed means that instead of having a single
central repository (like with traditional VCS), every
contributor has a full copy of the entire repository
on their local machine, including the entire history of
changes.
• Allows multiple people to work on a project
simultaneously without overwriting each other's
work
What is Git?
• Created by Linus Torvalds in 2005
• Developed to manage the Linux kernel development
• Initially, a solution to the shortcomings of previous systems
Key Features of Git
• Distributed
• Each developer has a complete history of the project
• Fast Performance
• Optimized for speed in managing changes
• Strong Support for Non-linear Development
• Branching and merging capabilities
Using Git
• Repository
• When you start a project with Git, you create a repository, which is like a
folder that tracks all your changes.
• Commits
• As you work on your project, you can save snapshots of your code, known
as commits. Each commit records what changed and why. If you make a
mistake, you can revert to a previous commit.
• Branches
• Git also has a powerful branching system, letting you create separate lines
of development within the same project. Once your changes are ready, you
merge the branch back into the main project.
Basic Git Workflow
• Working Directory
• Your local directory of files
• Staging Area (Index)
• Files marked for the next commit
• Repository
• Your project’s complete history
Initial Git Setup
Add your user information to git. This does NOT have to match your
github credentials, but it is better to do so.
Types
• feat : Commits, that adds or remove a new feature
• fix : Commits, that fixes a bug
• refactor : Commits, that rewrite/restructure your code, however
does not change any API behavior
• chore : is for everything else (writing documentation, formatting,
adding tests, cleaning useless code etc.)
Git Commit Naming Conventions
<type>: <description>
Description
• Think of the sentence “This commit will <<do this>>”
• In that case, the description should just include <<do this>>.
• Don't capitalize the first letter
• No dot (.) at the end
Git Commit Naming Conventions - Examples
Imagine each of these as the full sentence “This commit should …”.
• feat: add email notifications on new direct messages
• fix: add missing parameter to service call
• refactor: implement fibonacci number calculation as recursion
• chore: remove empty line
There should be a "/" followed by a description which sums up the purpose of this specific
branch. This description should be short and "kebab-cased".
Examples
• git branch feature/create-new-button-component
• git branch bugfix/button-overlap-form-on-mobile
Thank you