0% found this document useful (0 votes)
3 views18 pages

Lecture1Git Object Oriented Programming Python

The document provides an overview of Git and version control, emphasizing its importance for tracking changes, collaboration, and backup in software development. It details key features of Git, including its distributed nature, branching, and integration with platforms like GitHub and GitLab. Additionally, it includes practical instructions for installing, configuring, and using Git commands for repository management.

Uploaded by

jessicauviovo0
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)
3 views18 pages

Lecture1Git Object Oriented Programming Python

The document provides an overview of Git and version control, emphasizing its importance for tracking changes, collaboration, and backup in software development. It details key features of Git, including its distributed nature, branching, and integration with platforms like GitHub and GitLab. Additionally, it includes practical instructions for installing, configuring, and using Git commands for repository management.

Uploaded by

jessicauviovo0
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

Object Oriented Programming(Python)

Emmanuel Ali(PhD)

March 9, 2026

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 1 / 18


Outline

1 Git and Version Control

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 2 / 18


Version Control

Version control is a system that helps developers manage and track changes to
a project’s code, documents, or any other set of files. It serves several
essential purposes:
History Tracking: Version control systems (VCS) maintain a history of
changes made to files, including who made the changes and when. This
historical data is invaluable for debugging, auditing, and understanding
how a project evolves over time.
Collaboration: VCS enables multiple developers to work on the same
project simultaneously. It allows them to merge their changes, resolve
conflicts, and maintain a consistent codebase.
Backup and Recovery: VCS provide a secure backup of project files. In
case of data loss or accidental changes, you can revert to a previous state.
Branching and Parallel Development: VCS support branching, which
allows developers to work on separate features or bug fixes
independently. Branches can be merged when the work is complete.

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 3 / 18


Git
Git is a specific distributed version control system developed by Linus
Torvalds in 2005. It has become one of the most widely used version control
systems in the world. Here are some key concepts and features of Git:
Distributed: Git is a distributed version control system, which means
that every developer working on a project has a complete copy of the
entire repository, including the full history. This decentralization allows
for offline work and more robust collaboration.
Branching: Git makes branching easy and efficient. Developers can
create branches for new features, bug fixes, or experiments without
affecting the main codebase. Branches can be merged back into the main
branch when ready.
Commit: In Git, a commit represents a snapshot of the project at a
specific point in time. Each commit has a unique identifier (SHA-1 hash)
and includes changes made to files.
GitHub and GitLab: Git is often used in conjunction with online hosting
platforms like GitHub and GitLab. These platforms provide a central
location for hosting Git repositories, collaborative features, issue
tracking, and more.
Emmanuel Ali(PhD) 2nd Semester March 9, 2026 4 / 18
Git

Pull Requests (GitHub) or Merge Requests (GitLab): These features


allow contributors to propose changes to a repository and request that
they be merged into the main branch. Code review, discussions, and
automated testing can be integrated into this process.
Conflict Resolution: Git provides tools for resolving conflicts when
multiple people have edited the same part of a file. It helps prevent data
loss and ensures that changes are merged correctly.
Submodules: Git supports submodules, allowing you to include other Git
repositories within your project, which is useful for managing
dependencies.
Git is an essential tool in modern software development, enabling efficient
collaboration, tracking code changes, and providing a safety net for managing
complex projects. Learning how to use Git effectively is a valuable skill for
developers working on software projects of all sizes.

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 5 / 18


Git

Install Git:
First, you need to install Git on your computer if it’s not already
installed. You can download Git from the official website:
[Link]

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 6 / 18


Git

Configure Git:
After installation, open a terminal or command prompt and configure
your Git settings with your name and email address. This information
will be included in your commits.
git config -- global user . name " Your Name "
git config -- global user . email " youremail@example . com "

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 7 / 18


Git

Create a Git Repository:


To start using Git, you can either initialize a new Git repository or
clone an existing one. To create a new repository, navigate to the
project’s root directory in your terminal and run:
git init

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 8 / 18


Git

Add Files:
Use the git add command to stage files for tracking. You can add
specific files or all files in the directory.
# Stage a specific file
git add filename
# Stage all files in the current directory and its
subdirectories
git add .

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 9 / 18


Git

Make Commits:
Create a commit to record changes you’ve made to the staged files.
Include a descriptive commit message to explain the changes.
git commit -m " Added a new feature "

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 10 / 18


Git

View Commit History:


You can view the commit history using the git log command. This will
show a list of commits, their authors, timestamps, and commit
messages.
git log

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 11 / 18


Git

Create Branches:
Git allows you to create branches to work on different features or fixes
simultaneously. To create a new branch:
git branch new - feature

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 12 / 18


Git

Switch Branches:
To switch to a different branch, use the git checkout command:
git checkout new - feature

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 13 / 18


Git

Merge Branches:
Once you’ve completed your work on a branch, you can merge it into
another branch (usually the main branch) using the git merge
command:
git checkout main
git merge new - feature

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 14 / 18


Git

Resolve Conflicts:
If there are conflicts between branches (i.e., changes made in the same
part of a file), Git will require you to resolve them manually. Edit the
conflicted files, remove conflict markers, and commit the changes.

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 15 / 18


Git

Push to a Remote Repository:


If you’re collaborating with others, you can push your local repository
to a remote repository hosted on services like GitHub, GitLab, or
Bitbucket.
git remote add origin https :// github . com / username / repo .
git
git branch -M main
git push -u origin main

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 16 / 18


Git

Pull from a Remote Repository:


To get the latest changes from a remote repository, use the git pull
command:
git pull origin main

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 17 / 18


Git

Clone a Repository:
To work on an existing project, you can clone a remote repository to
your local machine:
git clone https :// github . com / username / repo . git

Emmanuel Ali(PhD) 2nd Semester March 9, 2026 18 / 18

You might also like