0% found this document useful (0 votes)
4 views19 pages

Version Control Assignment GIt & Git Hub

The document is an assignment on version control using Git and GitHub, detailing their importance in software development. It covers the concepts of version control, types of version control systems, and provides a comprehensive guide on how to use Git and GitHub, including workflows and best practices. Additionally, it highlights the benefits of using Git and GitHub for project management and collaboration.

Uploaded by

sohorab.bsmrstu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views19 pages

Version Control Assignment GIt & Git Hub

The document is an assignment on version control using Git and GitHub, detailing their importance in software development. It covers the concepts of version control, types of version control systems, and provides a comprehensive guide on how to use Git and GitHub, including workflows and best practices. Additionally, it highlights the benefits of using Git and GitHub for project management and collaboration.

Uploaded by

sohorab.bsmrstu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Noakhali Science And Technology

University

Assignment On
Topic: Documentation on Version Control (Git
+ GitHub)
Course Title: Data Structure & Algorithm
Course Code: PGD 211

Submitted to
Rafid Mostafiz
Assistant Professor
IIT( Institute Of Information Technology)
Noakhali Science and Technology University

Submitted By
Name : Emran Al Mahmud
Roll No : 202415001
Semester : 02
Batch No : PGDIT 15

Institute of Information Technology (IIT)


Contents

1. Introduction ................................................................................................................ 2

2. What is Version Control ............................................................................................ 2

3. Types of Version Control........................................................................................... 3

4. What is Git? ............................................................................................................... 4

05.What is GitHub? ....................................................................................................... 4

Git vs GitHub (Table) ................................................................................................ 4

06.How to Work on Github ........................................................................................... 5

07.Git Workflow (with Image) .................................................................................... 11

Benefits of Rebase: ............................................................................................... 14

8. Benefits of Using Git & GitHub .............................................................................. 16

9. Conclusion ............................................................................................................... 17

10. References .............................................................................................................. 18

Page | 1
1. Introduction
Version control is a system that helps developers track changes to code over time. It is
useful for managing projects, fixing errors, and working in teams. Git is a popular
version control tool that lets users work offline and save changes step-by-step.
Developers can create branches to test new features without affecting the main code.
GitHub is an online platform that stores Git projects and allows easy sharing and
teamwork. It includes tools like pull requests, issue tracking, and more. This
document explains how Git and GitHub work and why they are important in software
development today.

2. What is Version Control

Version control is a system that helps manage and track changes made to files over
time. It is mainly used in software development to monitor code updates, but it can
also be used for other types of documents. Version control allows developers to save
different versions of their work, compare changes, and return to an earlier version if
needed. This is especially helpful when fixing bugs or recovering lost code.

There are two main types of version control: centralized and distributed. In
centralized systems, all files are stored on a single server. Developers must be
connected to that server to make changes. In distributed systems like Git, every
developer has a complete copy of the project on their own computer. This allows
them to work offline and sync with others when needed.

Version control also supports team collaboration. When multiple people work on the
same project, version control helps prevent conflicts and confusion. Each person can
work on their own part, and later merge their changes with the main codebase.

Overall, version control makes software development faster, safer, and more
organized. It keeps a full history of the project, making it easy to manage, track
progress, and avoid mistakes.

Page | 2
3. Types of Version Control

There are three main types of version control systems: Local, Centralized, and
Distributed.

1. Local Version Control:


This is the most basic type. Changes are tracked
on a single computer. Developers manually save
versions of files. It is simple but risky—if the
computer is lost or damaged, all progress is lost.

2.Centralized Version Control (CVCS):

In this system, a central server stores all project files.


Developers connect to the server to get the latest
version and upload their changes. Examples include
Subversion (SVN). The main problem is that if the
server goes down, work stops.

Distributed Version Control (DVCS):

Here, every developer has a complete copy of the


project. Git is the most popular DVCS. Developers can
work offline and later sync their work with others. It’s
safer and more flexible than other systems.

Distributed systems are now the most widely used due to their reliability and ability to
support team collaboration effectively.

Page | 3
4. What is Git?
Git is a free and open-source version control system used to manage and track
changes in source code. It was created by Linus Torvalds in 2005, the same person
who developed Linux. Git helps developers keep a history of changes, work on
different parts of a project through branches, and collaborate with others easily.

Unlike older systems, Git is a distributed version control system (DVCS). This
means every developer has a full copy of the project on their computer. They can
work offline, and later sync their changes with others. Git also allows users to go back
to previous versions of the code, fix mistakes, and experiment safely without harming
the main project.

Git is fast, secure, and now widely used in software development worldwide.

05.What is GitHub?
GitHub is a web-based platform used to store and manage Git repositories online. It
helps developers work together on code, share projects, and track progress. While Git
is the tool that tracks code changes on your computer, GitHub lets you upload that
code to the internet so others can see it, use it, or help improve it.

GitHub provides useful features like pull requests, issue tracking, project boards,
and collaboration tools. Teams can review code, fix bugs, and discuss improvements
all in one place.

GitHub was launched in 2008 and is now owned by Microsoft. It supports both open-
source and private projects and is widely used by developers around the world.

Git vs GitHub (Table)


Git GitHub
Local version control tool Web-based hosting service
Works offline Requires internet access
Command-line based User-friendly web interface
Developed by Linus Torvalds Owned by Microsoft

Page | 4
06.How to Work on Github
GitHub is user-friendly and very easy to get started with. All we need to understand
the terms like fork, clone, pull requests, etc.

Let's learn how to use GitHub -

Step 1: Sign up for GitHub

GitHub is free. All we need to navigate to GitHub and create an account.

Step 2: Create our first repository on GitHub

Now we will create our very first repository on GitHub. - navigate to + icon and
select New Repository option -

It will open a new page asking about repository information like Repository
name, description and whether we want to make our project private or public, etc.

Fill the information and click Create repository button. Now we have successfully
created our first repository on GitHub.

Neat. As we can see we have our first repository on GitHub ready to grow as we work

Page | 5
Step 3: Install and set up Git

I have created a detailed tutorial on how to use Git. If you are not familiar with Git
uses and work-flow, it is recommended to read it first.Here is quick Git setup needed
to get started -

Download Git - Depending on your operating system download Git and follow the
installation window.

Right-click and select Git Bash option to initialize Git inside the project folder –

Set email -

git config --global user.email "[email protected]"

Git

Copy

Set name -

git config --global user.name "Your Name"

Git

Copy

Step 4: Clone the remote repository

Now we will clone the remote repository to our local system. This is because we will
be working on our local repository and pushing the change to GitHub repository very
frequently.

Navigate to the Github and click on Clone or Download button. It will open a
dropdown with our remote repository address.

Page | 6
Navigate to the location where you want to clone the repo. Right click and select ->
Git Bash option

To clone the repo we execute the below command -

git clone <remote_repo_address>

Git

Copy

So we will be running -

git clone https://github.com/YOUR_USERNAME/test-repo.git

Git

Copy

This will make a copy of the remote repository to our system.

Do not forget to replace YOUR_USERNAME with your GitHub username.

Now we are ready to work with this repository freely and make required changes.
Let's see how do we do it.

Step 5: Make changes to files

Let's start by updating our README.md file. Open it with your favorite editor and
make the changes. I update the content inside the README.md file.

Page | 7
Step 6: Add changes to the staging area

Now it is time to track changes and stage them. To check the status we run - git status

Let's add the changes to the staging area by running the git add . command -git add

Now if again run git status command, we see the newly created file has been tracked.

Step 6: Add changes to the staging area

Now it is time to track changes and stage them. To check the status we run - git status

Let's add the changes to the staging area by running the git add . command -git add .

Now if again run git status command, we see the newly created file has been tracked.

Step 7: Commit changes

Now it is time to commit these changes. Commit is a kind of record or snapshot of


what files have changed since the last time commit.

git commit -m "Update readme file"

Git

Copy

The commit message is written in quotes. This message will be saved with the
particular revision we did.

Page | 8
Great. So far, we have created a repository on GitHub, set up Git tool, cloned it on our
local system, made changes, added changes to the staging area and committed those
changes.

But our local changes are yet to be pushed to our remote repository.

Step 8: Push changes to the remote

It is time to push these changes to the server. To push the changes to remote -

git push

That is all. We have successfully pushed all our local changes to our remote
repository. If we goto our remote repository which we created, we can see that change
we made has een updated on GitHub.

Page | 9
So, now our basic work-flow is, every time we make any changes(modification,
adding new files or deleting unused ones) to the local repository -

stage changes (git add .)

commit changes (git commit -m "Commit message")

push to remote (git push)

Note that, it is must to commit changes before pushing it to the remote server.

Let's add a few files to our local repository. (Video)

- a homepage: index.html having


- a navbar, footer, and styling: style.css

Open the project directory with your favorite code editor( I am using Visual Studio
Code) -

Page | 10
07.Git Workflow (with Image)

1) Initial Setup: Preparing Your Git Environment

Before starting any project, ensure Git is installed and configured correctly.

Install Git

If you don’t have Git installed, download and install it from Git’s official website.
After installation, configure Git with your user details. These details are associated
with your commits.

Configure Git

This ensures every commit is tied to the correct author details.

Initialize a Git Repository

If you're starting a new project, you’ll need to initialize a Git repository:

This creates a .git directory that tracks your project’s changes. If you’re working on
an existing project, you can clone the repository:

Page | 11
2) Branching Strategy: Organizing Your Code

Branches are the foundation of Git workflows. Using branches effectively allows you
to isolate work, collaborate efficiently, and keep your production code stable.

Types of Branches

 main (or master) branch: The stable branch that always holds production-
ready code.
 develop branch: An integration branch for combining features before release
(used in Gitflow).
 Feature branches: Used for developing specific features or bug fixes. These
branches are temporary and merged back when the work is complete.
Create a New Branch

Before starting new work, ensure your main or develop branch is up-to-date:

checkout main
git pull origin main
Now, create a new branch for your feature:

/new-feature
This isolates your changes, keeping the stable branch clean.

3) Feature Branch Workflow: Managing Features Effectively

The Feature Branch Workflow is ideal for teams and individual developers. It
isolates development work into dedicated branches, ensuring the main branch remains
stable.

Steps:

1) Start from the latest main or develop:origin develop

2) Create a new branchure-name

3) Work on the feature and make small, frequent commits:

Page | 12
4) Push your branch to the remote repository:

5) Create a Pull Request (PR) for review:

 Go to your Git platform (e.g., GitHub, GitLab).


 Compare feature/feature-name with develop or main.
Add a description and assign reviewers. 6) Merge the branch after approval and
delete it:

4) Gitflow Workflow: Structured Development and Releases

Gitflow is a comprehensive workflow for managing features, releases, and hotfixes in


parallel. It's best for projects with scheduled releases.

Key Branches:

main: Production-ready code.


develop: The integration branch for testing and combining features.
feature: For new features.
release: For stabilizing and finalizing a release.
hotfix: For urgent production fixes.
Gitflow Steps:

1) Create a feature branch from develop:

git checkout develop


git pull origin develop
git checkout -b feature/feature-name
2) Merge completed features into develop:

git checkout develop


git merge feature/feature-name
git push origin develop
3) Create a release branch:

git checkout develop


git checkout -b release/v1.0.0
4) Merge the release branch into main and develop after finalizing:

git checkout main


git merge release/v1.0.0
git push origin main

Page | 13
git checkout develop
git merge release/v1.0.0
git push origin develop
5) For production bugs, use a hotfix branch:

git checkout main


git checkout -b hotfix/urgent-fix
# Apply fixes
git commit -m "Fix critical production issue"
git push origin hotfix/urgent-fix
5) Rebase Workflow: Keeping a Clean Commit History

Rebasing is a powerful Git feature that allows you to integrate changes from another
branch while maintaining a linear commit history. This is ideal for reducing noise in
your project’s history and avoiding unnecessary merge commits.

Steps:

1) Ensure your branch is up-to-date:

git checkout feature/feature-name


git fetch origin
git rebase origin/develop
2) Resolve conflicts, if any:

If conflicts arise, Git will pause the rebase and indicate the files in conflict.
Open the conflicted files, resolve the conflicts, then stage them:
git add <file>
Continue the rebase:
git rebase --continue
If necessary, you can abort the rebase and return to the original state:
git rebase --abort
3) Push the rebased branch to the remote:

Since rebasing rewrites history, you’ll need to force push:


git push --force
Benefits of Rebase:
Maintains a clean, linear history.
Eliminates unnecessary merge commits.
Makes it easier to review and trace changes.

6) Forking Workflow: Open-Source Collaboration

The Forking Workflow is essential for open-source projects where contributors don’t
have direct access to the main repository.

Page | 14
Steps:
1) Fork the repository into your GitHub account.
2) Clone the forked repository locally:

git clone <forked-repo-url>


3) Create a branch in your fork:

git checkout -b feature/contribution


4) Commit and push changes to your fork:

git add .
git commit -m "Fix bug in login functionality"
git push origin feature/contribution
5) Submit a pull request to the original repository.

7) Best Practices for Conflict-Free Collaboration

a) Keep Branches Up-to-Date

Regularly sync your branch with the base branch:

git fetch origin


git rebase origin/develop
b) Use Descriptive Commit Messages

Explain why the change was made:

git commit -m "Fix issue with form validation on login page"


c) Rebase Instead of Merge

Keep a clean history by rebasing:

git rebase develop


d) Review Code Thoroughly

Use Pull Requests to review code and catch issues early.

e) Clean Up Stale Branches

Delete branches after merging:

git branch -d feature/feature-name


git push origin --delete feature/feature-name

Page | 15
8. Benefits of Using Git & GitHub

1. It makes it easy to contribute to your open-source projects

To be honest, nearly every open-source project uses GitHub to manage its project.
Using GitHub is free if your project is open source and includes a wiki and issue
tracker that makes it easy to include more in-depth documentation and get feedback
about your project. If you want to contribute, you just fork a project, make your
changes and then send them a pull request using the GitHub web interface.

2. Documentation

By using GitHub, you make it easier to get excellent documentation. Their help
section and guides have articles for nearly any topic related to git that you can think o

3. Showcase your work

Are you a developer and wish to attract recruiters? GitHub is the best tool you can
rely on for this. Today, when searching for recruits for their project, most companies
look into GitHub profiles.

4. Markdown

Markdown allows you to use a simple text editor to write formatted documents.
GitHub has revolutionized writing by channeling everything through Markdown:
from the issue tracker to user comments, everything. With so many other
programming languages to learn for setting up projects.

5. GitHub is a repository

This was already mentioned before, but it’s important to note, GitHub is a repository.
This means that it allows your work to get out there in front of the public. Moreover,
GitHub is one of the largest coding communities around right now, so it’s wide
exposure for your project.

6. Track changes in your code across versions

When multiple people collaborate on a project, it’s hard to keep track of revisions—
who changed what, when, and where those files are stored. GitHub takes care of this
problem by keeping track of all the changes that have been pushed to the repository.

Page | 16
Much like using Microsoft Word or Google Drive, you can have a version history of
your code so that previous versions are not lost with every iteration.

7. Integration options

GitHub can integrate with common platforms such as Amazon and Google Cloud,
services such as Code Climate to track your feedback, and can highlight syntax in
over 200 different programming languages.

In conclusion, GitHub offers a multitude of benefits that can significantly enhance the
software development process for individuals and teams alike. From simplified version
control and seamless collaboration to robust project management and extensive community
support,

9. Conclusion

Version control is a critical aspect of modern software development, enabling teams


to work efficiently, safely, and collaboratively. Among the most widely used tools for
this purpose are Git and GitHub. Git is a distributed version control system that
allows developers to track changes, revert to previous states, and work on different
features simultaneously through branches. It ensures that every version of the code
is saved and can be restored if needed. GitHub, on the other hand, is a cloud-based
platform that hosts Git repositories and enhances collaboration through tools like pull
requests, issue tracking, and code reviews. Together, Git and GitHub provide a
seamless workflow for managing code, preventing conflicts, and ensuring
transparency within teams. They also offer backup, security, and integration with
other tools and services. This powerful combination significantly improves
productivity and makes the software development process more streamlined,
reliable, and scalable across both small and large teams.

Page | 17
10. References

 Atlassian Git Tutorials


https://www.atlassian.com/git/tutorials
 GeeksforGeeks: Git vs GitHub
https://www.geeksforgeeks.org/difference-between-git-and-github/
 GitHub Docs
https://docs.github.com/
 Git - Documentation
https://git-scm.com/doc
 A successful Git branching model (Vincent Driessen, nvie.com)
https://nvie.com/posts/a-successful-git-branching-model/
 Atlassian: Git Workflow
https://www.atlassian.com/git/tutorials/comparing-workflows
 GitHub Flow (GitHub Guides)
https://guides.github.com/introduction/flow/
 Git Rebase vs Merge (Atlassian)
https://www.atlassian.com/git/tutorials/merging-vs-rebasing
 Benefits of Using Git & GitHub (freeCodeCamp)
https://www.freecodecamp.org/news/what-is-git-and-how-to-use-it-
c341b049ae61/
 How to Use Git and GitHub (DigitalOcean Community Tutorials)
https://www.digitalocean.com/community/tutorial_series/git-and-github

Page | 18

You might also like