Software Development Podcast Show in India

India’s First Software Development Podcast Show

SDP Show # 4 : Source Control and Basics of Git & GitHub

Are you new to source control? Today’s show is on Source control and the basics of Git & GitHub.

Revision control, source control or source code management plays a very important role in today’s software development process.

Students and developers should use source control for their projects because it allows distributed work in teams of any size, at different locations while avoiding any source code changes.

software development podcast show

Please feel free to download the MP3 directly. Listen to it, when you drive to work, are stuck in traffic, or wait for your flight.

Subscribe our podcast show on iTunes


Get Podcast in your mailbox









Read the whole transcript

Join NOW for FREE : Basics of Git and GitHub course in HINDI Language on Udemy

What is source control? Basics of Git and GitHub

are you new to source control? Today’s show is on Source control and the basics of git & GitHub.

Revision control, source control or source code management plays a very important role in today’s software development process.

Students and developers should use source control for their projects because it allows distributed work in teams of any size, at different locations while avoiding any source code changes.

Let’s talk about source control in simple words “source control also knows as version control and source code management is the management of multiple revisions of the same unit of information.

Next let’s talk about the basic concepts of git

Git: Basic Concepts

what is a repository

A repository is simply a database containing all the information needed to retain and manage the revisions and history of a project. Within a repository, Git maintains two primary data structures, the object store and the index.

The object store is designed to be efficiently copied during a clone operation as part of the mechanism that supports a fully DVCS.

Index is transitory information, is private to a repository and can be created or modified on demand as needed.

Git Object Store

It contains your original data files and all the log messages, author information, dates, and other information required to rebuild any revision or branch of the project.

There are four types of Object stores

  • Blobs: A blob holds a file’s data but does not contain any metadata about the file or even its name.

  • Trees: It records blob identifiers, path names and a bit of metadata for all the files in a directory.

  • Commits: A commits object holds metadata for each change introduced into the repository, including the author, committer, commit data, and log message.

  • Tags: A tag object assigns an arbitrary human readable name to a specific object usually a commit.

Index

the index is a temporary and dynamic binary file that describes the directory structure of the entire repository.

Index captures a version of the project’s overall structure at some moment in time. As the developer, we execute Git commands to stage changes in the index. Changes usually add, delete or edit some files or set of files. The index records and retains those changes, keeping them safe until you are ready to commit them. You can also remove or replace changes in the index.

Content-Addressable Names

the Git object store is organized and implemented as a content-addressable storage system. Each object in the object store has a unique name produced by applying SHA1 to the contents of the object, yielding an SHA1 hash value. Any tiny change to a file causes the SHA1 hash to change, causing the new version of the file to be indexed separately.

SHA1 values are 160-bit value that are usually represented as a 40 digit hexadecimal number.

For example 937082042f48a5cbc7777634509310fff059bc19

File Management and The Index

Index

Git’s Index doesn’t contain any file content: it simply tracks what you want to commit when you run git commit. Git checks the index rather than your working directory to discover what to commit.

You can query the state of the index at any time with the command git status

File Classification in Git

  • Tracked : Any file that’s already there in the repository or any file that is staged
  • Ignored : file to be ignored by git object store and git index
  • Untracked : An untracked file is any file not found in either of the previous two categories

Git Commands

.gitignore file ### (I forget to discuss command in the podcast but its discussed in the course)

add any file name in the .gitignore file which you want to ignore

Git Command Line Commands

add, branch, checkout,clone,commit,diff,init,log,merge,mv,pull,push,rebase,reset,rm,show,status

Git Version Check

git –version

Creating an initial repository

git init

Adding file to your repository

git add index.html

Git status

git status

Configuring the commit author

git config user.name “abhishekluv”

git config user.email “abhishekluv@gmail.com

Git Commit

git commit -m “commit message”

git commit –message=“commit message”

Viewing your commits

git log

Show branch

git show-branch –more=10

Removing a file in your repository

git rm index.html

Global commit author details

git config –global user.name “abhishekluv”

git config –global user.email “abhishekluv@gmail.com

Branches

A branch is the fundamental means of launching a separate line of development within a software project.

Git allows many branches and thus many different lines of development within a repository.

Creating a branch

git branch branchname

list branches

git branch

list of branches with details

git show-branch

changing/checking out branches

git checkout branchname

creating and checking out a new branch

git checkout -b branchname

deleting a branch

git branch -d branchname

Merges

what is git merge

In Git, a merge must occur within a single repository i.e. all the branches to be merged must be present in the same repository

git checkout branch

git merge other_branch

git commit -a -m “commit message”

Comments