SlideShare a Scribd company logo
Gitting it under
(version) control
The Plan

•   What is Version Control?

•   Git Basics

•   Workflows

•   Other fun stuff
What is Version
        Control?
• It’s exactly what it sounds like.
• Sometimes called SCM (source control
  management).
• One codebase, one project.
• Lots of people changing it to get things
  done at the same time.
  •   How do we track those changes?

  •   How do we make sure I don’t step over your toes?
Different Approaches


•   Distributed vs. Centralized

•   Delta vs. Directed Acyclic Graph (DAG)
Muscle Memory FTW

# 0. Get a copy of the repository
git clone git@github.com:user/repo
# 1. Before you do any work...
git pull
# 2. Do work, edit files, but when you want to share it...
git commit -am "commit message"
# 3. Now send it to everyone else
git push
# GOTO Step 1.
Setting Up

•     Download Installer
    from http://git-scm.com/

•    A few commands you
    want to run right away:

git config --global user.name "Ankur Oberoi"
git config --global user.email "aoberoi@gmail.com"
git config --global color.ui true
git commands
•   Porcelain (high-level, “nice” for users)
     git−add          git−commit   git−log        git−reset
     git−branch       git−diff     git−mv         git−status
     git−checkout     git−fetch    git−merge      git−push
     git−clone        git-init     git−pull       git−tag
     git-archive      git-bisect   git-bundle     git-cherry-pick
     git-citool       git-clean    git-describe   git-format-patch
     ...              ...          ...            ...


•   Plumbing (low-level, deals with database & filesystem)

    git−apply         git−checkout−index   git−commit−tree      git−hash
    −object
    git−index−pack    git−init−db          git−merge−index      git−mktag
    git−mktree        git−pack−objects     git−prune−packed     git−read−tree
    git−repo−config   git−unpack−objects   git−update−index     git−write−tree
    git−cat−file      git−describe         git−diff−index       git−diff−files
    git-diff-index    git-diff-tree        git-for-each-ref     git-ls-files
    ...               ...                  ...                  ...
Getting a repository
•   One project, one .git (hidden) directory

•   Start it from initial code locally

                     •      git init


•   Clone it from somewhere else
                 •       git clone URL
Local Repository Operations




Working Directory   Staging Area   Repository
 “Working Tree”       “Index”      “Database”
Local Repository Operations


Readme.md
* AwesomeProj *

AwesomeProj
does x and y.




     Working Directory   Staging Area   Repository
      “Working Tree”       “Index”      “Database”
Local Repository Operations

  git add Readme.md


                    Readme.md
                    * AwesomeProj *

                    AwesomeProj
                    does x and y.




Working Directory        Staging Area   Repository
 “Working Tree”            “Index”      “Database”
Local Repository Operations

  git add Readme.md                  git commit -m “commit mess”


                                          Readme.md
                                          * AwesomeProj *

                                          AwesomeProj
                                          does x and y.




Working Directory     Staging Area           Repository
 “Working Tree”         “Index”              “Database”
Local Repository Operations
                     git status


     # On branch master
     nothing to commit (working directory clean)


Readme.md




 Working Directory    Staging Area        Repository
  “Working Tree”        “Index”           “Database”
Local Repository Operations
                             git status



# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   Readme.md
    (use "git checkout -- <file>..." to discard changes in working
        Readme.md
directory)
#   * AwesomeProj *
# modified:   Readme.md
#
no changes added to commit (use "git add" and/or "git commit -a")
    AwesomeProj
    does x, y and z.




         Working Directory    Staging Area       Repository
          “Working Tree”        “Index”          “Database”
Local Repository Operations
                         git status

            git add Readme.md
            # On branch master
            # Changes to be committed:
            #   (use "git reset HEAD <file>..."
            to unstage)
                   Readme.md
Readme.md   #
            # modified:   Readme.md
            #      * AwesomeProj *

                     AwesomeProj
                     does x, y and z.




 Working Directory        Staging Area     Repository
  “Working Tree”            “Index”        “Database”
Local Repository Operations

                                      git commit -m “new feat”



Readme.md                                    Readme.md
 [master ad9e3bf] new feat
1 files changed, 1 insertions(+), 1 deletions(-)
                                        * AwesomeProj           *

                                             AwesomeProj
                                             does x, y and z.




 Working Directory     Staging Area           Repository
  “Working Tree”         “Index”              “Database”
Local Repository Operations
                     git status

     # On branch master
     nothing to commit (working directory clean)


Readme.md




 Working Directory    Staging Area        Repository
  “Working Tree”        “Index”           “Database”
Local Repository Operations

         git add Readme.md                  git commit -m “commit mess”




       Working Directory     Staging Area           Repository
        “Working Tree”         “Index”              “Database”

git reset HEAD Readme.md
Local Repository Operations

         git add Readme.md                  git commit -m “commit mess”




                 X
        git checkout -- Readme.md


                  X
                  git checkout HEAD -- Readme.md
                  git reset --hard [HEAD]


       Working Directory     Staging Area           Repository
        “Working Tree”         “Index”              “Database”

git reset HEAD Readme.md
Branching & Merging
•       What is a commit?

    •    An object that points to trees/blobs in the .git directory

    •    addressed by a SHA1 hash (ad9e3b)

    •    contains info about author/commiter

    •    also contains pointers to “parent commits”
                              ad9e3b
Branching & Merging
•       What is a branch?
    •    A pointer to a commit

    •    logically, a separate concern in development

•       What is HEAD?
    •    A pointer to a branch
                             ad9e3b        master       HEAD
    •    Usually represents whats in the WT *now*
Branching & Merging
    git commit -m “new feature”



   ad9e3b      master       HEAD
Branching & Merging
    git commit -m “new feature”



   ad9e3b      master       HEAD
Branching & Merging
    git commit -m “new feature”



   ad9e3b



   c88da7       master      HEAD
Branching & Merging
                git branch issue8



       ad9e3b

                       master       HEAD

       c88da7
                       issue8




New branch for a separate logical concern
Branching & Merging
                      git checkout issue8



             ad9e3b

                             master

             c88da7
                             issue8         HEAD



Checkout actually changes the files in your Working
                       Tree
Branching & Merging
# Make changes in editor, add changes to staging...
git commit -m “redoing data structure”



          ad9e3b

                                     master

          c88da7

                        b9711f       issue8      HEAD




New commits have pointers to parent(s)
Branching & Merging
                      git checkout master



             ad9e3b

                                            master   HEAD

             c88da7
                             b9711f         issue8




Checkout actually changes the files in your Working
                       Tree
Branching & Merging
       # Making more commits...



   ad9e3b



   c88da7        b9711f       issue8




   f327e3                    master    HEAD
Branching & Merging
# Now we need to get that fix for issue8 into master
                  git merge issue8



         ad9e3b



         c88da7         b9711f       issue8




         f327e3                     master       HEAD
Branching & Merging
# Now we need to get that fix for issue8 into master
                  git merge issue8
 ad9e3b




 c88da7         b9711f       issue8




 f327e3          This is known as a “merge commit”

 a77106                     master       HEAD
Sharing Code with
             Remotes
•       How do we share code with others?

    •    git has stored URLs with aliases called “remotes”


    •     a few operations to move code from your local repository
        to and from a remote

    •    you get local copies of remote branches in your repo


    •    *branch related operations happen locally
Remotes
  •    By default, you always get one remote
      when you clone, it is called “origin”

  •     You can add more remotes using:
git remote add github git@github.com:aoberoi/testproj.git



      This URL can be ssh:// (most common),
        http://, https://, git://, or even file:///
Using Remotes
f327e3   master   HEAD
Using Remotes
                     origin/master HEAD

           f327e3

                     master      HEAD




Now what if someone else adds commits to origin?
Using Remotes
                             master      HEAD


f327e3

            3602ea           origin/master HEAD




  This new commit only exists on the server...
                 git fetch origin
Using Remotes
                         master      HEAD


f327e3

          3602ea        origin/master HEAD




         Now we have a local copy.
How do we continue working where the latest
         from the server left off?
Using Remotes
                            master      HEAD


f327e3

           3602ea           origin/master HEAD



 How do we continue working where the latest
          from the server left off?
             git merge origin/master
Using Remotes
              f327e3           master      HEAD




             3602ea            origin/master HEAD



                git merge origin/master


Fast-forward merge: my commit is in the history of
             what is to be merged in
Using Remotes
               f327e3          master     HEAD




              3602ea          origin/master HEAD



                  Pull is a shortcut:
           git pull = git fetch + git merge
No need to specify the argument to merge if you are
              on a “tracking branch”
Creating a Tracking
          Branch

•    If theres a new branch available on the
    server and you want to participate in
    developing on that “logical concern”
        git checkout -t origin/next-big-thing


      You are not checking out a remote
                   branch,
         you are creating a new one
Pushing Changes


•     Pushing can only be fast-forward commits,
    this prevents you from abandoning
    someone else’s changes
               git push origin master
Inspection and History

•   git log --pretty=oneline --graph

•   git diff [--cached]

•   git status

•   git remote show
Other Neat Tricks
•   git add -u

•   git stash

•   git push -u origin master

•   git push origin :badfeature

•   git log feature ^master

•   git add -i
Gotchas

•   Binary files? Images? Videos? Databases?

•   Detached HEAD

•   non fast-forward

•   git rm / git mv
Workflows
master is always
         deployable
•    Good general convention

•    Keep actual development on ‘topic’
    branches

•     When topic is complete and code is
    tested → merge (or pull request)
                      master



                     issue-8
master is always
         deployable
•    Good general convention

•    Keep actual development on ‘topic’
    branches

•     When topic is complete and code is
    tested → merge (or pull request)
                      master


                    issue-8
Local Development
•       Common pieces to share:

    •    unit tests


    •    graphics


    •    utility scripts


•    Keep your own preferences on your local
    machine and don’t commit them
.gitignore

•     A file with filename patterns that you
    don’t want to become part of your index
    (nor your commits)

•    See samples for all types of platforms:
    https://github.com/github/gitignore/
Mark versions with
              Tags
•       Tags are like “unmovable” branches

•     This makes it a good bookmark to keep
    track of code that was released

    •     “I need to patch a bug that my customer sees, but what
        code did I deploy?”
Github Pull-Requests
•    You don’t always have access to push if
    you are contributing to open source, send a
    pull-request

•       Pull-requests work from branch to branch

    •    use this for collaborative development


    •    code review


•       http://www.confreaks.com/videos/706-
Github Forks

•    Just a “clone” that you initialize on a
    remote server, instead of on your machine

•    Holds a little bit of history for the project
    so you can track relationships in a
    “network”
IDE and GUI Tools
      Xcode
IDE and GUI Tools
      Eclipse Egit
IDE and GUI Tools
•       Platform Specific Tools

    •     Tower for Mac


    •     TortoiseGit for Windows


•       Cross Platform

    •     gitk
Feeling more “at home”

•   Bash Completion

•   Merge Tool

•   Commit Message Editor

•   Aliases
Left as an exercise for
      the readers
•   cherry-picking
•   “rewriting” history
•   git-svn
•   git modules
•   environment variables and $GIT_DIR
•   Treeishes by ‘x’spec
•   Writing your own git hooks
Resources
•    Git Cheatsheet (visual)
    http://ndpsoftware.com/git-cheatsheet.html
•    Github Help
    http://help.github.com/git-cheat-sheets/
•    Pro Git
    http://progit.org/book/
•    Git Community Book
    http://book.git-scm.com/
•   Google Tech Talk with Linus Torvalds
Erasing any
Preconceived Notions
• If you came from svn, you have a separate
  understanding of version control
• commits happen locally (actually almost
  everything happens locally)
• version numbers are not monotonically
  increasing
• branches are not global (pollution of
  namespace?)
• merging is (relatively) cheap, can be done
Why distributed over
   centralized?
• Offline development
• Easy to do experimental work
• ... code review
• ... other workflowy specific purposes
  (flexibility)
• “commit access” politics are avoided
• backups
Ad

More Related Content

What's hot (20)

Gitlikeapro 2019
Gitlikeapro 2019Gitlikeapro 2019
Gitlikeapro 2019
Jesús Miguel Benito Calzada
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
Hiroshi SHIBATA
 
Hadoop 설치
Hadoop 설치Hadoop 설치
Hadoop 설치
Taehoon Kim
 
Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)
Felix Geisendörfer
 
“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.
Graham Dumpleton
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
Felix Geisendörfer
 
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
Felix Geisendörfer
 
Apache Cassandra and Go
Apache Cassandra and GoApache Cassandra and Go
Apache Cassandra and Go
DataStax Academy
 
Apache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteApache Hadoop Shell Rewrite
Apache Hadoop Shell Rewrite
Allen Wittenauer
 
Deploying E.L.K stack w Puppet
Deploying E.L.K stack w PuppetDeploying E.L.K stack w Puppet
Deploying E.L.K stack w Puppet
Colin Brown
 
Apache Hive Hook
Apache Hive HookApache Hive Hook
Apache Hive Hook
Minwoo Kim
 
May 2012 HUG: Oozie: Towards a scalable Workflow Management System for Hadoop
May 2012 HUG: Oozie: Towards a scalable Workflow Management System for HadoopMay 2012 HUG: Oozie: Towards a scalable Workflow Management System for Hadoop
May 2012 HUG: Oozie: Towards a scalable Workflow Management System for Hadoop
Yahoo Developer Network
 
Chef & OpenStack: OSCON 2014
Chef & OpenStack: OSCON 2014Chef & OpenStack: OSCON 2014
Chef & OpenStack: OSCON 2014
Matt Ray
 
Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용
종민 김
 
Velocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopVelocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack Workshop
Chef Software, Inc.
 
Atlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Atlanta OpenStack 2014 Chef for OpenStack Deployment WorkshopAtlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Atlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Matt Ray
 
July 2012 HUG: Overview of Oozie Qualification Process
July 2012 HUG: Overview of Oozie Qualification ProcessJuly 2012 HUG: Overview of Oozie Qualification Process
July 2012 HUG: Overview of Oozie Qualification Process
Yahoo Developer Network
 
Hadoop Oozie
Hadoop OozieHadoop Oozie
Hadoop Oozie
Madhur Nawandar
 
MongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster TutorialMongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster Tutorial
Jason Terpko
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
CoreOS
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
Hiroshi SHIBATA
 
“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.
Graham Dumpleton
 
Apache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteApache Hadoop Shell Rewrite
Apache Hadoop Shell Rewrite
Allen Wittenauer
 
Deploying E.L.K stack w Puppet
Deploying E.L.K stack w PuppetDeploying E.L.K stack w Puppet
Deploying E.L.K stack w Puppet
Colin Brown
 
Apache Hive Hook
Apache Hive HookApache Hive Hook
Apache Hive Hook
Minwoo Kim
 
May 2012 HUG: Oozie: Towards a scalable Workflow Management System for Hadoop
May 2012 HUG: Oozie: Towards a scalable Workflow Management System for HadoopMay 2012 HUG: Oozie: Towards a scalable Workflow Management System for Hadoop
May 2012 HUG: Oozie: Towards a scalable Workflow Management System for Hadoop
Yahoo Developer Network
 
Chef & OpenStack: OSCON 2014
Chef & OpenStack: OSCON 2014Chef & OpenStack: OSCON 2014
Chef & OpenStack: OSCON 2014
Matt Ray
 
Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용
종민 김
 
Velocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack WorkshopVelocity 2011 Chef OpenStack Workshop
Velocity 2011 Chef OpenStack Workshop
Chef Software, Inc.
 
Atlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Atlanta OpenStack 2014 Chef for OpenStack Deployment WorkshopAtlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Atlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Matt Ray
 
July 2012 HUG: Overview of Oozie Qualification Process
July 2012 HUG: Overview of Oozie Qualification ProcessJuly 2012 HUG: Overview of Oozie Qualification Process
July 2012 HUG: Overview of Oozie Qualification Process
Yahoo Developer Network
 
MongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster TutorialMongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster Tutorial
Jason Terpko
 
CoreOS in a Nutshell
CoreOS in a NutshellCoreOS in a Nutshell
CoreOS in a Nutshell
CoreOS
 

Viewers also liked (7)

The Seven Deadly Coding Sins Slides
The Seven Deadly Coding Sins SlidesThe Seven Deadly Coding Sins Slides
The Seven Deadly Coding Sins Slides
mobiledevnj
 
квест-проект посвящённый 70летию Великой Победы
квест-проект посвящённый 70летию Великой Победы квест-проект посвящённый 70летию Великой Победы
квест-проект посвящённый 70летию Великой Победы
Sample Splat
 
Delegation Slides
Delegation SlidesDelegation Slides
Delegation Slides
mobiledevnj
 
Ama ieee takeda
Ama ieee takedaAma ieee takeda
Ama ieee takeda
m-takeda
 
Bab 4
Bab 4Bab 4
Bab 4
Novia Firmansah
 
Tarea daa sesion3
Tarea daa sesion3Tarea daa sesion3
Tarea daa sesion3
albycom7274
 
Storyboards Slides
Storyboards SlidesStoryboards Slides
Storyboards Slides
mobiledevnj
 
The Seven Deadly Coding Sins Slides
The Seven Deadly Coding Sins SlidesThe Seven Deadly Coding Sins Slides
The Seven Deadly Coding Sins Slides
mobiledevnj
 
квест-проект посвящённый 70летию Великой Победы
квест-проект посвящённый 70летию Великой Победы квест-проект посвящённый 70летию Великой Победы
квест-проект посвящённый 70летию Великой Победы
Sample Splat
 
Delegation Slides
Delegation SlidesDelegation Slides
Delegation Slides
mobiledevnj
 
Ama ieee takeda
Ama ieee takedaAma ieee takeda
Ama ieee takeda
m-takeda
 
Tarea daa sesion3
Tarea daa sesion3Tarea daa sesion3
Tarea daa sesion3
albycom7274
 
Storyboards Slides
Storyboards SlidesStoryboards Slides
Storyboards Slides
mobiledevnj
 
Ad

Similar to Gitting It Under (Version) Control (20)

簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
Grace Chien
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
Alberto Leal
 
Git training
Git trainingGit training
Git training
eric7master
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
 
T3dd10 git
T3dd10 gitT3dd10 git
T3dd10 git
jugglefish
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
Chris Johnson
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
Pranesh Vittal
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
UshaSuray
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git presentation
Git presentationGit presentation
Git presentation
James Cuzella
 
Git slides
Git slidesGit slides
Git slides
Nguyen Van Hung
 
Gittalk
GittalkGittalk
Gittalk
prtinsley
 
Source control management
Source control managementSource control management
Source control management
Owen Winkler
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Source control management
Source control managementSource control management
Source control management
Owen Winkler
 
Ad

Recently uploaded (20)

IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 

Gitting It Under (Version) Control

  • 2. The Plan • What is Version Control? • Git Basics • Workflows • Other fun stuff
  • 3. What is Version Control? • It’s exactly what it sounds like. • Sometimes called SCM (source control management). • One codebase, one project. • Lots of people changing it to get things done at the same time. • How do we track those changes? • How do we make sure I don’t step over your toes?
  • 4. Different Approaches • Distributed vs. Centralized • Delta vs. Directed Acyclic Graph (DAG)
  • 5. Muscle Memory FTW # 0. Get a copy of the repository git clone [email protected]:user/repo # 1. Before you do any work... git pull # 2. Do work, edit files, but when you want to share it... git commit -am "commit message" # 3. Now send it to everyone else git push # GOTO Step 1.
  • 6. Setting Up • Download Installer from http://git-scm.com/ • A few commands you want to run right away: git config --global user.name "Ankur Oberoi" git config --global user.email "[email protected]" git config --global color.ui true
  • 7. git commands • Porcelain (high-level, “nice” for users) git−add git−commit git−log git−reset git−branch git−diff git−mv git−status git−checkout git−fetch git−merge git−push git−clone git-init git−pull git−tag git-archive git-bisect git-bundle git-cherry-pick git-citool git-clean git-describe git-format-patch ... ... ... ... • Plumbing (low-level, deals with database & filesystem) git−apply git−checkout−index git−commit−tree git−hash −object git−index−pack git−init−db git−merge−index git−mktag git−mktree git−pack−objects git−prune−packed git−read−tree git−repo−config git−unpack−objects git−update−index git−write−tree git−cat−file git−describe git−diff−index git−diff−files git-diff-index git-diff-tree git-for-each-ref git-ls-files ... ... ... ...
  • 8. Getting a repository • One project, one .git (hidden) directory • Start it from initial code locally • git init • Clone it from somewhere else • git clone URL
  • 9. Local Repository Operations Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 10. Local Repository Operations Readme.md * AwesomeProj * AwesomeProj does x and y. Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 11. Local Repository Operations git add Readme.md Readme.md * AwesomeProj * AwesomeProj does x and y. Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 12. Local Repository Operations git add Readme.md git commit -m “commit mess” Readme.md * AwesomeProj * AwesomeProj does x and y. Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 13. Local Repository Operations git status # On branch master nothing to commit (working directory clean) Readme.md Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 14. Local Repository Operations git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # Readme.md (use "git checkout -- <file>..." to discard changes in working Readme.md directory) # * AwesomeProj * # modified: Readme.md # no changes added to commit (use "git add" and/or "git commit -a") AwesomeProj does x, y and z. Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 15. Local Repository Operations git status git add Readme.md # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) Readme.md Readme.md # # modified: Readme.md # * AwesomeProj * AwesomeProj does x, y and z. Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 16. Local Repository Operations git commit -m “new feat” Readme.md Readme.md [master ad9e3bf] new feat 1 files changed, 1 insertions(+), 1 deletions(-) * AwesomeProj * AwesomeProj does x, y and z. Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 17. Local Repository Operations git status # On branch master nothing to commit (working directory clean) Readme.md Working Directory Staging Area Repository “Working Tree” “Index” “Database”
  • 18. Local Repository Operations git add Readme.md git commit -m “commit mess” Working Directory Staging Area Repository “Working Tree” “Index” “Database” git reset HEAD Readme.md
  • 19. Local Repository Operations git add Readme.md git commit -m “commit mess” X git checkout -- Readme.md X git checkout HEAD -- Readme.md git reset --hard [HEAD] Working Directory Staging Area Repository “Working Tree” “Index” “Database” git reset HEAD Readme.md
  • 20. Branching & Merging • What is a commit? • An object that points to trees/blobs in the .git directory • addressed by a SHA1 hash (ad9e3b) • contains info about author/commiter • also contains pointers to “parent commits” ad9e3b
  • 21. Branching & Merging • What is a branch? • A pointer to a commit • logically, a separate concern in development • What is HEAD? • A pointer to a branch ad9e3b master HEAD • Usually represents whats in the WT *now*
  • 22. Branching & Merging git commit -m “new feature” ad9e3b master HEAD
  • 23. Branching & Merging git commit -m “new feature” ad9e3b master HEAD
  • 24. Branching & Merging git commit -m “new feature” ad9e3b c88da7 master HEAD
  • 25. Branching & Merging git branch issue8 ad9e3b master HEAD c88da7 issue8 New branch for a separate logical concern
  • 26. Branching & Merging git checkout issue8 ad9e3b master c88da7 issue8 HEAD Checkout actually changes the files in your Working Tree
  • 27. Branching & Merging # Make changes in editor, add changes to staging... git commit -m “redoing data structure” ad9e3b master c88da7 b9711f issue8 HEAD New commits have pointers to parent(s)
  • 28. Branching & Merging git checkout master ad9e3b master HEAD c88da7 b9711f issue8 Checkout actually changes the files in your Working Tree
  • 29. Branching & Merging # Making more commits... ad9e3b c88da7 b9711f issue8 f327e3 master HEAD
  • 30. Branching & Merging # Now we need to get that fix for issue8 into master git merge issue8 ad9e3b c88da7 b9711f issue8 f327e3 master HEAD
  • 31. Branching & Merging # Now we need to get that fix for issue8 into master git merge issue8 ad9e3b c88da7 b9711f issue8 f327e3 This is known as a “merge commit” a77106 master HEAD
  • 32. Sharing Code with Remotes • How do we share code with others? • git has stored URLs with aliases called “remotes” • a few operations to move code from your local repository to and from a remote • you get local copies of remote branches in your repo • *branch related operations happen locally
  • 33. Remotes • By default, you always get one remote when you clone, it is called “origin” • You can add more remotes using: git remote add github [email protected]:aoberoi/testproj.git This URL can be ssh:// (most common), http://, https://, git://, or even file:///
  • 34. Using Remotes f327e3 master HEAD
  • 35. Using Remotes origin/master HEAD f327e3 master HEAD Now what if someone else adds commits to origin?
  • 36. Using Remotes master HEAD f327e3 3602ea origin/master HEAD This new commit only exists on the server... git fetch origin
  • 37. Using Remotes master HEAD f327e3 3602ea origin/master HEAD Now we have a local copy. How do we continue working where the latest from the server left off?
  • 38. Using Remotes master HEAD f327e3 3602ea origin/master HEAD How do we continue working where the latest from the server left off? git merge origin/master
  • 39. Using Remotes f327e3 master HEAD 3602ea origin/master HEAD git merge origin/master Fast-forward merge: my commit is in the history of what is to be merged in
  • 40. Using Remotes f327e3 master HEAD 3602ea origin/master HEAD Pull is a shortcut: git pull = git fetch + git merge No need to specify the argument to merge if you are on a “tracking branch”
  • 41. Creating a Tracking Branch • If theres a new branch available on the server and you want to participate in developing on that “logical concern” git checkout -t origin/next-big-thing You are not checking out a remote branch, you are creating a new one
  • 42. Pushing Changes • Pushing can only be fast-forward commits, this prevents you from abandoning someone else’s changes git push origin master
  • 43. Inspection and History • git log --pretty=oneline --graph • git diff [--cached] • git status • git remote show
  • 44. Other Neat Tricks • git add -u • git stash • git push -u origin master • git push origin :badfeature • git log feature ^master • git add -i
  • 45. Gotchas • Binary files? Images? Videos? Databases? • Detached HEAD • non fast-forward • git rm / git mv
  • 47. master is always deployable • Good general convention • Keep actual development on ‘topic’ branches • When topic is complete and code is tested → merge (or pull request) master issue-8
  • 48. master is always deployable • Good general convention • Keep actual development on ‘topic’ branches • When topic is complete and code is tested → merge (or pull request) master issue-8
  • 49. Local Development • Common pieces to share: • unit tests • graphics • utility scripts • Keep your own preferences on your local machine and don’t commit them
  • 50. .gitignore • A file with filename patterns that you don’t want to become part of your index (nor your commits) • See samples for all types of platforms: https://github.com/github/gitignore/
  • 51. Mark versions with Tags • Tags are like “unmovable” branches • This makes it a good bookmark to keep track of code that was released • “I need to patch a bug that my customer sees, but what code did I deploy?”
  • 52. Github Pull-Requests • You don’t always have access to push if you are contributing to open source, send a pull-request • Pull-requests work from branch to branch • use this for collaborative development • code review • http://www.confreaks.com/videos/706-
  • 53. Github Forks • Just a “clone” that you initialize on a remote server, instead of on your machine • Holds a little bit of history for the project so you can track relationships in a “network”
  • 54. IDE and GUI Tools Xcode
  • 55. IDE and GUI Tools Eclipse Egit
  • 56. IDE and GUI Tools • Platform Specific Tools • Tower for Mac • TortoiseGit for Windows • Cross Platform • gitk
  • 57. Feeling more “at home” • Bash Completion • Merge Tool • Commit Message Editor • Aliases
  • 58. Left as an exercise for the readers • cherry-picking • “rewriting” history • git-svn • git modules • environment variables and $GIT_DIR • Treeishes by ‘x’spec • Writing your own git hooks
  • 59. Resources • Git Cheatsheet (visual) http://ndpsoftware.com/git-cheatsheet.html • Github Help http://help.github.com/git-cheat-sheets/ • Pro Git http://progit.org/book/ • Git Community Book http://book.git-scm.com/ • Google Tech Talk with Linus Torvalds
  • 60. Erasing any Preconceived Notions • If you came from svn, you have a separate understanding of version control • commits happen locally (actually almost everything happens locally) • version numbers are not monotonically increasing • branches are not global (pollution of namespace?) • merging is (relatively) cheap, can be done
  • 61. Why distributed over centralized? • Offline development • Easy to do experimental work • ... code review • ... other workflowy specific purposes (flexibility) • “commit access” politics are avoided • backups