Version Control
Version Control
Reading Material
Topics
Understanding the concept
Version control system
Git
Github
SVN
Local Repository
Remote Repository
Git installation
Git setup
.gitignore file
Some important git commit
Staging in Git
Stashing in Git
Branching Strategy
Some advanced git commands
Interview Questions
Multiple Choice Questions
Git
Git is a VCS, which means it helps developers manage changes to their code over time. It allows you to track
modifications, collaborate with others, and maintain a history of the project.
PW Skills
PW Skills
GitHub
GitHub is a platform where you can upload a copy of your Git repository (often shortened as repo), hosted
either on github.com. More than just uploading your Git repositories it allows you to collaborate much more
easily with other people on your projects. It does that by providing a centralized location to share the repository,
a web-based interface to view it, and features like forking, Pull requests, Issues, Projects, and GitHub Wikis that
allow you to specify, discuss, and review changes with your team more effectively.
SVN
SVN (Subversion) is a centralized version control system that allows multiple developers to collaborate on a
project by storing files and their history on a central server. SVN simplifies the coding process, facilitates access
management, and optimizes storage space by enabling developers to keep only the files they are working on
locally and commit them to the server when ready.
In contrast, Git is a distributed version control system that utilizes multiple repositories, including a central
repository and local repositories. Git's workflow involves creating local repositories that mirror the central
repository, allowing developers to work on their local copies and push changes to the central repository when
ready
Local Repository
A local repository in the context of software development typically refers to a Git repository that is stored on
your local machine. it is used for version control features, but collaboration features like pulling and pushing
code changes with teammates can only be done on a remote repository.
Remote Repository
A remote repository, also known as a remote in version control systems like Git, is a copy of your project that's
stored on the internet or another network. It acts like a central location for your codebase, allowing for
collaboration and version control.
Git installation
For the installation of Git on any system, certain specific instructions should be followed depending on a
particular operating system-
Windows
Visit the official Git for Windows website i.e. Lin
Download the latest installer (64-bits is recommended
Run the installer and follow the installation wizar
During the installation, one can choose various configuration options. The default settings are usually fine for
most users.
Mac -
For installing it Mac OS Homebrew should be installed from the official Homebrew site i.e. Link
After installing the Homebrew run the following command below to install the git.
PW Skills
brew install git
Git setup
Setup or Configure your user information used across all local repositories
// user name
// user email
.gitignore file
The .gitignore file is a text file used in Git repositories to specify which files or directories should be ignored by
Git. It is typically placed in the root directory of a project and contains patterns that match files or directories to
be excluded from version control.
.gitignore
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
git init
git clone
git status
PW Skills
// 6. git push - save all commit chanes to remote
repository
git log
git fetch
git pull
Staging in Git
Staging refers to preparing changes in your working directory to be included in the next commit. When you
make changes to files in your Git repository, these changes are initially considered to be in the "unstaged" state.
Staging involves selectively choosing which changes you want to include in the next commit.
git add
Stashing in Git
Stashing refers to temporarily saving your work in progress, including both staged and unstaged changes, on a
stack of unfinished changes that you can reapply later.
PW Skills
// save modified and staged changes
git stash
// clear stash
Branching strategy
A branching strategy in Git is a set of guidelines that define how developers create, manage, and merge
branches within a project. It essentially establishes a workflow for collaborating on the codebase and keeping it
organized.
// create branch
// list branch
git branch
git reflog
PW Skills