You are on page 1of 24

What is version control?

Version control, also known as source control, is the practice of tracking and managing changes to
software code.

Version control systems (VCS) are software tools that help software teams manage changes to source
code over time.
Types of VCS tools

- Distributed

- Centralized
Types of VCS tools (cont.d)

- Centralized

- Has a single point of failure.


Types of VCS tools (cont.d)

- Distributed
Why do we need VCS and benefits of
VCS tools.
- Conflict resolution
Benefits of VCS tools (cont.d)
- Rollback and undo changes to source code
Benefits of VCS tools (cont.d)
- Offsite source code backup
Benefits of VCS tools (cont.d)
- Other benefits include

- Team communication

- Extended 3rd party integrations

- CI/CD pipeline automation

- Insight, measurement and accountability


Version Control System (VCS) tools
Git and GitHub Intro

-What is Git?

- Version control system.

- It was created by Linus Torvalds in 2005 to develop Linux


Kernel

- Maintained by Junio Hamano (Japanese software engineer)

- Tracking code changes

- Tracking who made changes

- Coding collaboration
Git and GitHub Intro

-Features of Git?
- Open Source
- Scalable
- Distributed
- Security
- Speed
- Branching and merging
- Data assurance
- Staging area
- Maintain the clean history
Git and GitHub Intro

-Benefits of Git?
- Saves Time
- Offline Working
- Undo Mistakes
- Track the Changes
Why Git?

- Over 96.65% of developers use Git!


- So it’s a trendy version control system
- Work together from anywhere in the world.
- See the full history of the project.
- Revert to earlier versions of a project.
- Impress Recruiters
What is GitHub?
- Git repository hosting service
- Git is not the same as GitHub.
- A remote repository platforms
- Hosted on the web/internet.
- Makes tools that use Git.
- Largest host of source code in the world.
- Owned by Microsoft since 2018.
Practice Time!
- Git installed?
- $ git –-version
- git version 2.x.x…

if not installed:
- Mac users:
- $ brew install git
- Windows users:
- Download and install from https://gitforwindows.org/
Practice Time!
- Configure git to use your name and email
address for all commits by the current user

$ git config --global user.name ”Test User”


$ git config --global user.email test@test.com

Verify user configs:


$ git config --list | grep user
Practice Time!
- Create a test directory
- $ mkdir –p seytech/test
- $ cd seytech/test

- $ ls –la

- Initialize git repository


- $ git init
- $ ls –la

- $ git remote -v
Practice Time!
- Create a new repo in Github

- $ git remote add origin


https://github.com/agaparov-relay/react-app-test.git

- $ git remote -v
origin https://github.com/agaparov-relay/react-app-test.git (fetch)
origin https://github.com/agaparov-relay/react-app-test.git (push)

- $ ls –l

- $ git pull origin main

- $ git branch (List all branches in the current repo)


Practice Time!
- $ git status (List which files are staged, unstaged, and
untracked)

- $ git log (Display the entire commit history)

- $ git log --oneline (Display commits in one line)

- $ git add <filename> (Stage a file)

- $ git add . (Stage all changes)

- $ git commit –m “Initial commit”

- $ git push
- $ git push --set-upstream origin main
Practice Time!
- $ git branch <new-branch>
- $ git branch
- $ git checkout <new-branch>
Practice Time!
- $ git checkout –b <new-branch>
- $ git branch
Practice Time!
- Delete a merged branch
- $ git branch –d <branch-name>

- Deleting unmerged branches


- $ git branch -d newb
error: The branch 'newb' is not fully merged.
If you are sure you want to delete it, run 'git branch -D
newb'.
- Delete a branch whether it is merged or not
- $ git branch –D <branch-name>
Practice Time!
- Clone a repo from Github
- $ git clone <repo-url>

- $ cd <repo-name>
- $ git branch
Questions?

You might also like