Optimizing AI for immediate response in Smart CCTV
git- Most Of The Things About a Trending DVCS
1. git
MOST OF THE THINGS ABOUT A TRENDING DVCS
ISURU WIMALASUNDERA
2. VERSION CONTROL
▸ version control , revision control & source control are
referring to the same…
▸ version control systems are to manage the changes done
on software programs, documents and any collection of
information .
▸ Centralized version control systems (CVCS) and
Distributed version (DVCS)
▸ CVCS - CVS , Subversion (SVN) , Perforce
3. DVCS …
▸ Mercurial, Git and Bazaar
▸ Has a central repository But ….
▸ Do not rely on that central repo to
store all the versions of a project.
▸ every developer “clones” a copy of
the central repository.
▸ The “clone” copy has the full history
and all meta-data of the original.
▸ “pull” to get new change, “push” to
add new change.
4. ADVANTAGES & DISADVANTAGES OF DVCS
▸ pushing and pulling changes are fast , as it is not accessing
a remote server but your own hard drive.
▸ offline commit of changes.
▸ can commit a set of changes without affecting others.
▸ Others can refer ones local repository and check changes.
▸ If the main repo is very large and has long history it can
consume large amount of space and lot of time to
download.
5. "I'M AN EGOTISTICAL BASTARD, AND I NAME ALL MY
PROJECTS AFTER MYSELF. FIRST 'LINUX', NOW 'GIT'."
Linus Torvalds
6. GIT - HOW IT ALL BEGINS
▸ founded by Linus Torvalds and the
Linux Kernel team
▸ From 1991 to 2002 modifications to
linux kernel was kept in file system as
patches.
▸ Linux moved to BitKeeper a
proprietary DVCS in 2002.
▸ BitKeeper revoked the free usage for
linux team, and Linux Kernel team
started writing their own DVCS.
▸ so came the git , and the rest is
history….
8. INSTALLING GIT …
▸ Installing git - enough references are there in Google
▸ Installation methods are platform specific.
9. UNDERSTANDING GIT CORE
▸ git is a content-addressable filesystem, bit like Unix.
▸ means that at the core of Git is a simple key-value data
store.
▸ The key is a 40-character checksum hash.
▸ value can be different types of git objects.
▸ git Object types
▸ Tree Objects, Blob Objects, Commit Objects & Tag
Objects
10. UNDERSTANDING GIT CORE (CONTD.)
▸ Tree Objects represent the
repository. (similar to a folder/
directory in a file system)
▸ Blob objects are the leafs , any file
in the repository. (similar to files in
a file system)
▸ Commit Objects the functional
object of repository current status.
▸ Tag Objects categorise a commit
object by naming it.
▸ A good reference
▸ https://git-scm.com/book/en/
v2/Git-Internals-Git-Objects
11. CREATE YOUR GIT REPOSITORY
▸ Configure your git
▸ git config --global user.name "Your Name"
▸ git config --global user.email you@example.com
▸ Go in to your project and initialise a git repository.
▸ git init
▸ Add all the project directories and files to repository.
▸ git add .
▸ Now Commit all the added directories and files to git.
▸ git commit -m “<commit-message>”
12. WHERE IS THE GIT REPOSITORY ?
▸ Its there along with the project files, look for a hidden file
“.git” , a single folder , in the project root.
▸ The git repository contains
▸ Head file
▸ Objects
▸ branches
▸ logs and many more
14. USEFUL GIT COMMANDS AT THIS STAGE
▸ git log - shows a log of all commits starting from HEAD
back to the initial commit.
▸ git status - shows which files have changed between
the current project state and HEAD.
▸ git diff - shows the diff between HEAD and the current
project state.
▸ git mv and git rm - mark files to be moved (rename)
and removed, respectively, much like git add.
15. HOW DOES GIT COMMIT WORKS ?
▸ git commit is the current status of repository.
▸ Represented by the Commit Object, the commit object
contains follows.
▸ The set of files currently available (changed/unchanged).
▸ Reference to parent commit (the SHA1 key of parent
commit).
▸ The SHA1 name.
▸ git add will add files to the commit object, current versions
of changed files, previous version of unchanged / un-
added files.
16. HOW DOES GIT COMMIT WORKS ? (CONTD.)
▸ git commit will submit the commit object, a commit is a
snapshot of the repository.
▸ Now the “new commit object” is the current status of the
git repository.
17. GIT BRANCHING
▸ Manage drastic changes, new features.
▸ Manage a different copy of the “master” within same
repository. which means another commit object.
▸ create a branch.
▸ git branch <name>
▸ Point HEAD to the new branch.
▸ git checkout <branch_name>
▸ Better to manage “trunk” & “branch” practice.
18. GIT MERGING
▸ If we are merging the branch to master, set HEAD to
master. And then merge
▸ git checkout master
▸ git merge <branch_name>
▸ Then do a new git commit.
19. CONFLICT RESOLUTION
▸ At the point of merging , if master repository has
changed from the ancestor commit, then conflicts can
happen at the point of merging.
▸ Git will add conflict messages at exact points.
▸ Manually edit those locations and commit.
20. COLLABORATIVE DEVELOPMENT
▸ Get someones git repository ,
▸ git clone <repo_url>
▸ Create a remote repo reference named as “origin”.
▸ Then new heads will get created pointing to the header
of remote repo, known as “remote heads”
▸ origin/master - for the master head
▸ origin/<branch> - for the branches
21. COLLABORATIVE DEVELOPMENT (CONTD.)
▸ create your own branch to work on the remote repository
branch.
▸ git branch --track [new-local-branch] [remote-
branch]
▸ get updates from remote branch.
▸ git fetch origin
▸ Now update your local “master” and branches with the
updates.
▸ git pull origin <master/branch_name>