Working on a Project
Managing Versions of a Document
We keep making many changes when building software or even writing anything.
Advantages of Versioning
We can quickly revert back to any of the older versions or pick up changes from an older version.
We can check how the files are modified over time.
Managing Versions of a Project
When working on a software project, we keep making changes to existing files to add new features and fix existing bugs
Collaboration
When working on a huge project with many files which is being developed by multiple people it is hard to manually keep track of the changes.
- Any small change may completely crash the project.
Versioning
When working with multiple people, it is useful to know,
Who made changes to a given file?
When are these made changes made?
Source Code Management
Version Control System
Each change to project can be considered a new version of the project.
Version Control System simplifies tracking changes to the project and allow us switch back to any previous version.
There are several tools that help us manage versions of the source code of software.
Git
Subversion
Mercurial
Git
Git is a free, open-source and most widely used distributed version control system.
- A software used for tracking changes in any set of files.
Repository
A Git Repository (Repo) is like a database which maintains different versions of the project files.
Snapshots
Git allows us to take a snapshot of our project files to create versions of the project.
These versions or snapshots are referred to as commits in Git Terminology
Tracking Files
By default, Git doesn’t track changes to a file and doesn’t maintain versions automatically.
We have to explicitly specify git to track file changes and save versions.
Selecting Specific Changes
Most of the times we want to have a selective set of changes as part of the snapshot.
Git creates a snapshot of all the changes that are part of staging area.
Git’s View of Repository
Untracked Files : The set of files whose changes are not tracked by Git.
Tracked Files: The set of files which are watched by Git for any changes.
Modified Files: These are the files which are modified after the latest snapshot.
Staged Files: The set of files which are about to be committed to create a new snapshot.
Committed Files: These are the unmodified files which are same since the latest commit.
Distributed Version Control System
Git is a distributed version control system.
- Everyone has a copy of the entire repository with the entire version history.
Git Repository
There are several cloud-based repository hosting services which let you maintain a copy of repository
GitHub
Bitbucket
Create Account
Create Github account by visiting https://github.com
Creating a Repository
Create a new Github repository using + button at top right corner of website.
After clicking on New repository button you can see screen similar to below.
After creating github repository you can be able to see screen similar to below.
Sharing Repository
We can share the repository with other users on GitHub to collaborate.
You can invite collaborators by visiting settings > Manage access and clicking on Invite a collaborator.
Git Client
Installing git in your system to manage & work with Git Repositories.
In Linux :
In MAC :
Setting Author Info
Configure who gets credit for the changes made from your device by setting the author details from your terminal.
Command Line Coloring For Git
To set automatic command line coloring for Git for easy reviewing.
Viewing Git Client Configuration
You can check your current git client’s configuration with
Sample output :
Cloning Repository
Cloning a repository downloads all versions of the files that ever existed to your computer.
The
.git/folder present in the repository contains all these versions and information required for version control.
Example :
Displaying the Remote
Lists the details of the configured remote repo.
Sample output :
Initializing a Git Repository
Apart from cloning a repo, you can also initialize a git repo in an existing folder.
Useful when you want to convert an existing, unversioned project to a Git repository or initialize a new, empty repository.
- git initinitializes an empty git repository in the working directory.
Syntax :
Adding Remote Repository
Syntax :
Example :
From August 12, 2021, Github has disabled authentication of