SlideShare ist ein Scribd-Unternehmen logo
1 von 343
Git: a brief introduction


            Randal Schwartz
        merlyn@stonehenge.com
  http://www.stonehenge.com/merlyn/
      Version 3.01 on 12-Jan-2010
Disclaimer
Disclaimer
●   I've been tracking git since it was created
Disclaimer
●   I've been tracking git since it was created
●   I've used git on small projects
Disclaimer
●   I've been tracking git since it was created
●   I've used git on small projects
●   I've used other systems on small and large
    projects
Disclaimer
●   I've been tracking git since it was created
●   I've used git on small projects
●   I've used other systems on small and large
    projects
●   I've read a lot of people talk about git on
    the mailing list
Disclaimer
●   I've been tracking git since it was created
●   I've used git on small projects
●   I've used other systems on small and large
    projects
●   I've read a lot of people talk about git on
    the mailing list
●   I've even provided some patches to git, and
    suggestions for user interface changes
Disclaimer
●   I've been tracking git since it was created
●   I've used git on small projects
●   I've used other systems on small and large
    projects
●   I've read a lot of people talk about git on
    the mailing list
●   I've even provided some patches to git, and
    suggestions for user interface changes
●   I have worked on small and medium teams
    with git
Disclaimer
●   I've been tracking git since it was created
●   I've used git on small projects
●   I've used other systems on small and large
    projects
●   I've read a lot of people talk about git on
    the mailing list
●   I've even provided some patches to git, and
    suggestions for user interface changes
●   I have worked on small and medium teams
    with git
●   But not large ones
What is git?
What is git?
●   Git manages changes to a tree of files over
    time
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
    −   Being very fast
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
    −   Being very fast
    −   Being robust
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
    −   Being very fast
    −   Being robust
●   Git is not optimized for:
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
    −   Being very fast
    −   Being robust
●   Git is not optimized for:
    −   Tracking file permissions and ownership
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
    −   Being very fast
    −   Being robust
●   Git is not optimized for:
    −   Tracking file permissions and ownership
    −   Tracking individual files with separate history
What is git?
●   Git manages changes to a tree of files over
    time
●   Git is optimized for:
    −   Distributed development
    −   Large file sets
    −   Complex merges
    −   Making trial branches
    −   Being very fast
    −   Being robust
●   Git is not optimized for:
    −   Tracking file permissions and ownership
    −   Tracking individual files with separate history
    −   Making things painful
Why git?
Why git?
●   Essential to Linux kernel development
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
    −   Clone the tree
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
    −   Clone the tree
    −   Make and test local changes
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
    −   Clone the tree
    −   Make and test local changes
    −   Submit the changes as patches via mail
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
    −   Clone the tree
    −   Make and test local changes
    −   Submit the changes as patches via mail
    −   OR submit them as a published repository
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
    −   Clone the tree
    −   Make and test local changes
    −   Submit the changes as patches via mail
    −   OR submit them as a published repository
    −   Track the upstream to revise if needed
Why git?
●   Essential to Linux kernel development
●   Created as a replacement when BitKeeper
    suddenly became “unavailable”
●   Everybody has a “commit bit”
●   Anyone can:
    −   Clone the tree
    −   Make and test local changes
    −   Submit the changes as patches via mail
    −   OR submit them as a published repository
    −   Track the upstream to revise if needed
●   Kernel.org is just a convenient public
    watering hole
How does git do it?
How does git do it?
●   Universal public identifiers
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
●   Efficient object storage
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
●   Efficient object storage
●   Everyone has entire repo (disk is cheap)
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
●   Efficient object storage
●   Everyone has entire repo (disk is cheap)
●   Easy branching and merging
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
●   Efficient object storage
●   Everyone has entire repo (disk is cheap)
●   Easy branching and merging
    −   Common ancestors are computable
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
●   Efficient object storage
●   Everyone has entire repo (disk is cheap)
●   Easy branching and merging
    −   Common ancestors are computable
●   Patches (and repo updates) can be
    transported or mailed
How does git do it?
●   Universal public identifiers
    −   None of the SVK “my @245 is your @992”
●   Multi-protocol transport
    −   HTTP
    −   SSH
    −   GIT
●   Efficient object storage
●   Everyone has entire repo (disk is cheap)
●   Easy branching and merging
    −   Common ancestors are computable
●   Patches (and repo updates) can be
    transported or mailed
●   Binary “patches” are supported
The SHA1 is King
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
         ●   Plus a message about why
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
         ●   Plus a message about why
    −   Tags:
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
         ●   Plus a message about why
    −   Tags:
         ●   An object (usually a commit)
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
         ●   Plus a message about why
    −   Tags:
         ●   An object (usually a commit)
         ●   Plus a subject
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
         ●   Plus a message about why
    −   Tags:
         ●   An object (usually a commit)
         ●   Plus a subject
         ●   Plus an optional payload to sign it off
The SHA1 is King
●   Every “object” has a SHA1 to uniquely
    identify it
●   “objects” consist of:
    −   Blobs (the contents of a file)
    −   Trees (directories of blobs or other trees)
    −   Commits:
         ●   A tree
         ●   Plus zero or more parent commits
         ●   Plus a message about why
    −   Tags:
         ●   An object (usually a commit)
         ●   Plus a subject
         ●   Plus an optional payload to sign it off
         ●   Plus an optional gpg signature
Objects live in the repo
Objects live in the repo
●   Git efficiently creates new objects
Objects live in the repo
●   Git efficiently creates new objects
●   Objects are generally added, not destroyed
Objects live in the repo
●   Git efficiently creates new objects
●   Objects are generally added, not destroyed
●   Unreferenced objects (deleted branch,
    added but not committed, etc) can be
    garbage collected
Objects live in the repo
●   Git efficiently creates new objects
●   Objects are generally added, not destroyed
●   Unreferenced objects (deleted branch,
    added but not committed, etc) can be
    garbage collected
●   Objects start “loose”, but can be “packed”
    for filesystem efficiency
Objects live in the repo
●   Git efficiently creates new objects
●   Objects are generally added, not destroyed
●   Unreferenced objects (deleted branch,
    added but not committed, etc) can be
    garbage collected
●   Objects start “loose”, but can be “packed”
    for filesystem efficiency
●   “Packs” often represent objects as deltas for
    space efficiency
Objects live in the repo
●   Git efficiently creates new objects
●   Objects are generally added, not destroyed
●   Unreferenced objects (deleted branch,
    added but not committed, etc) can be
    garbage collected
●   Objects start “loose”, but can be “packed”
    for filesystem efficiency
●   “Packs” often represent objects as deltas for
    space efficiency
●   “Packs” are also created for transfer
    between repositories
Commits rule the repo
Commits rule the repo
●   One or more commits form the head of
    object chains
Commits rule the repo
●   One or more commits form the head of
    object chains
●   Typically one head called “master”
Commits rule the repo
●   One or more commits form the head of
    object chains
●   Typically one head called “master”
●   Others can be made at will (“branches”)
Commits rule the repo
●   One or more commits form the head of
    object chains
●   Typically one head called “master”
●   Others can be made at will (“branches”)
●   All reachable repo objects are accessed
    from these head commits
Commits rule the repo
●   One or more commits form the head of
    object chains
●   Typically one head called “master”
●   Others can be made at will (“branches”)
●   All reachable repo objects are accessed
    from these head commits
    −   Chase down the tree object to get to directories
        and files as they existed at this commit time
Commits rule the repo
●   One or more commits form the head of
    object chains
●   Typically one head called “master”
●   Others can be made at will (“branches”)
●   All reachable repo objects are accessed
    from these head commits
    −   Chase down the tree object to get to directories
        and files as they existed at this commit time
    −   Chase down the parent objects to get to earlier
        commits and their respective trees
Commits rule the repo
●   One or more commits form the head of
    object chains
●   Typically one head called “master”
●   Others can be made at will (“branches”)
●   All reachable repo objects are accessed
    from these head commits
    −   Chase down the tree object to get to directories
        and files as they existed at this commit time
    −   Chase down the parent objects to get to earlier
        commits and their respective trees
●   Usually one commit in the repo that has no
    parent commit
Mapping objects to a file tree
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
    −   refs/heads/* – branches (like “master”)
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
    −   refs/heads/* – branches (like “master”)
    −   refs/tags/* - tags
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
    −   refs/heads/* – branches (like “master”)
    −   refs/tags/* - tags
    −   logs/* - logs
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
    −   refs/heads/* – branches (like “master”)
    −   refs/tags/* - tags
    −   logs/* - logs
    −   refs/remotes/* - tracking others
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
    −   refs/heads/* – branches (like “master”)
    −   refs/tags/* - tags
    −   logs/* - logs
    −   refs/remotes/* - tracking others
    −   index – the “index cache” (described shortly)
Mapping objects to a file tree
●   A “working tree” has a “.git” dir at the top
    level
●   Unlike CVS, SVN: no pollution of deeper
    directories (“grep -r” friendly)
●   The .git dir contains:
    −   config – Configuration file (.ini style)
    −   objects/* – The object repository
    −   refs/heads/* – branches (like “master”)
    −   refs/tags/* - tags
    −   logs/* - logs
    −   refs/remotes/* - tracking others
    −   index – the “index cache” (described shortly)
    −   HEAD – points to one of the branches (the
        “current branch”, where commits go)
The index (or “cache”)
The index (or “cache”)
●   A directory of blob objects
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
●   Diff between HEAD and index:
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
●   Diff between HEAD and index:
    −   changed things not yet committed
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
●   Diff between HEAD and index:
    −   changed things not yet committed
●   Diff between index and working dir:
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
●   Diff between HEAD and index:
    −   changed things not yet committed
●   Diff between index and working dir:
    −   changed things not yet added
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
●   Diff between HEAD and index:
    −   changed things not yet committed
●   Diff between index and working dir:
    −   changed things not yet added
    −   untracked things
The index (or “cache”)
●   A directory of blob objects
●   Represents the “next commit”
●   “Add files” to put them in the index,
    including current content
●   “Commit” takes the current index and
    makes it a real commit object.
●   Diff between HEAD and index:
    −   changed things not yet committed
●   Diff between index and working dir:
    −   changed things not yet added
    −   untracked things
●   Index gets interesting during a merge
The great renaming
   controversy
The great renaming
            controversy
●   Git doesn’t record explicit renaming
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
●   Exact renaming can be determined by SHA1
    comparisons
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
●   Exact renaming can be determined by SHA1
    comparisons
●   Copy-paste-edits can be detected by ad-
    hoc “similarity” rules for logs
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
●   Exact renaming can be determined by SHA1
    comparisons
●   Copy-paste-edits can be detected by ad-
    hoc “similarity” rules for logs
●   In general the computer can find these far
    easier than you can
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
●   Exact renaming can be determined by SHA1
    comparisons
●   Copy-paste-edits can be detected by ad-
    hoc “similarity” rules for logs
●   In general the computer can find these far
    easier than you can
●   If you make it explicit, it will be wrong
    sometimes
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
●   Exact renaming can be determined by SHA1
    comparisons
●   Copy-paste-edits can be detected by ad-
    hoc “similarity” rules for logs
●   In general the computer can find these far
    easier than you can
●   If you make it explicit, it will be wrong
    sometimes
●   Being wrong breaks merges
The great renaming
            controversy
●   Git doesn’t record explicit renaming
●   Nor expect you to declare it
●   Exact renaming can be determined by SHA1
    comparisons
●   Copy-paste-edits can be detected by ad-
    hoc “similarity” rules for logs
●   In general the computer can find these far
    easier than you can
●   If you make it explicit, it will be wrong
    sometimes
●   Being wrong breaks merges
●   Even being right will break some merges!
Git speaks and listens
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
    −   import/export with SVN
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
    −   import/export with SVN
    −   import from Arch
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
    −   import/export with SVN
    −   import from Arch
●   I use CVS/SVN import to have entire history
    of a project at 30K feet
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
    −   import/export with SVN
    −   import from Arch
●   I use CVS/SVN import to have entire history
    of a project at 30K feet
●   Third party solutions handle others
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
    −   import/export with SVN
    −   import from Arch
●   I use CVS/SVN import to have entire history
    of a project at 30K feet
●   Third party solutions handle others
●   Git core also includes cvs-server
Git speaks and listens
●   Many protocols to transfer git data between
    repositories
    −   rsync, http, https, git, ssh, local files
●   In the core, git also has:
    −   import/export with CVS
    −   import/export with SVN
    −   import from Arch
●   I use CVS/SVN import to have entire history
    of a project at 30K feet
●   Third party solutions handle others
●   Git core also includes cvs-server
    −   A git repository can act like a CVS repository for
        legacy clients or humans
Getting git
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
●   RPMs and Debian packages also exist
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
●   RPMs and Debian packages also exist
●   Once you’ve bootstrapped git, git-clone the
    git-developer archive
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
●   RPMs and Debian packages also exist
●   Once you’ve bootstrapped git, git-clone the
    git-developer archive
    −   git-clone git://git.kernel.org/pub/scm/git/
        git.git
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
●   RPMs and Debian packages also exist
●   Once you’ve bootstrapped git, git-clone the
    git-developer archive
    −   git-clone git://git.kernel.org/pub/scm/git/
        git.git
●   Rebuild once a week or so
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
●   RPMs and Debian packages also exist
●   Once you’ve bootstrapped git, git-clone the
    git-developer archive
    −   git-clone git://git.kernel.org/pub/scm/git/
        git.git
●   Rebuild once a week or so
●   Maintenance releases are very stable
Getting git
●   Get the latest “git-*.tar.gz” from http://
    www.kernel.org/pub/software/scm/git/
●   RPMs and Debian packages also exist
●   Once you’ve bootstrapped git, git-clone the
    git-developer archive
    −   git-clone git://git.kernel.org/pub/scm/git/
        git.git
●   Rebuild once a week or so
●   Maintenance releases are very stable
●   I install mine “prefix=/opt/git”, and add
    /opt/git/bin to my PATH
Git commands
Git commands
●   All git commands start with “git”
Git commands
●   All git commands start with “git”
●   “git MUMBLE-FOO bar” has also been
    written as “git-MUMBLE-FOO bar”
Git commands
●   All git commands start with “git”
●   “git MUMBLE-FOO bar” has also been
    written as “git-MUMBLE-FOO bar”
●   This allows a single entry “git” to be added
    to the /usr/local/bin path
Git commands
●   All git commands start with “git”
●   “git MUMBLE-FOO bar” has also been
    written as “git-MUMBLE-FOO bar”
●   This allows a single entry “git” to be added
    to the /usr/local/bin path
●   This works for internal calls as well
Git commands
●   All git commands start with “git”
●   “git MUMBLE-FOO bar” has also been
    written as “git-MUMBLE-FOO bar”
●   This allows a single entry “git” to be added
    to the /usr/local/bin path
●   This works for internal calls as well
●   The manpages are still under “git-MUMBLE-
    FOO”, so you have to know the convention
    either way
Git commands
●   All git commands start with “git”
●   “git MUMBLE-FOO bar” has also been
    written as “git-MUMBLE-FOO bar”
●   This allows a single entry “git” to be added
    to the /usr/local/bin path
●   This works for internal calls as well
●   The manpages are still under “git-MUMBLE-
    FOO”, so you have to know the convention
    either way
    −   Unless you use “git help MUMBLE-FOO”
Git commands
●   All git commands start with “git”
●   “git MUMBLE-FOO bar” has also been
    written as “git-MUMBLE-FOO bar”
●   This allows a single entry “git” to be added
    to the /usr/local/bin path
●   This works for internal calls as well
●   The manpages are still under “git-MUMBLE-
    FOO”, so you have to know the convention
    either way
    −   Unless you use “git help MUMBLE-FOO”
    −   Or “git MUMBLE-FOO --help”
“The Internet is just a series
          of tubes”
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
●   We’ll stick with the git porcelain in the rest
    of this talk, unless otherwise noted
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
●   We’ll stick with the git porcelain in the rest
    of this talk, unless otherwise noted
●   Other porcelain exists:
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
●   We’ll stick with the git porcelain in the rest
    of this talk, unless otherwise noted
●   Other porcelain exists:
     −   StGit (“stacked git”)
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
●   We’ll stick with the git porcelain in the rest
    of this talk, unless otherwise noted
●   Other porcelain exists:
     −   StGit (“stacked git”)
     −   guilt
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
●   We’ll stick with the git porcelain in the rest
    of this talk, unless otherwise noted
●   Other porcelain exists:
     −   StGit (“stacked git”)
     −   guilt
     −   tig (curses-based viewer)
“The Internet is just a series
              of tubes”
●   Low-level git operations are called
    “plumbing”
●   Higher level actions are called “porcelain”
●   The git distro includes git plumbing and git
    porcelain (git-gui)
●   We’ll stick with the git porcelain in the rest
    of this talk, unless otherwise noted
●   Other porcelain exists:
     −   StGit (“stacked git”)
     −   guilt
     −   tig (curses-based viewer)
     −   qgit
Creating a repo
Creating a repo
●   git-init
Creating a repo
●   git-init
    −   Creates a .git in the current dir
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
●   git-clone REMOTESPEC
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
●   git-clone REMOTESPEC
    −   Creates a git repo from an existing repo
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
●   git-clone REMOTESPEC
    −   Creates a git repo from an existing repo
    −   Generally creates a subdirectory
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
●   git-clone REMOTESPEC
    −   Creates a git repo from an existing repo
    −   Generally creates a subdirectory
    −   Your workfiles and .git are in there
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
●   git-clone REMOTESPEC
    −   Creates a git repo from an existing repo
    −   Generally creates a subdirectory
    −   Your workfiles and .git are in there
    −   All remote branches are “tracked”
Creating a repo
●   git-init
    −   Creates a .git in the current dir
    −   Optional: edit .gitignore
    −   “git-add .” to add all files (except .git!)
    −   Then “git commit” for the initial commit
    −   Creates a branch named “master”
    −   HEAD points at “master”
●   git-clone REMOTESPEC
    −   Creates a git repo from an existing repo
    −   Generally creates a subdirectory
    −   Your workfiles and .git are in there
    −   All remote branches are “tracked”
    −   Remote “HEAD” branch checked out as your
        initial “master” branch as well
Think globally, work locally
Think globally, work locally
●   Your work product is more commits
Think globally, work locally
●   Your work product is more commits
●   These are always on a “branch”
Think globally, work locally
●   Your work product is more commits
●   These are always on a “branch”
●   A branch is just a named commit
Think globally, work locally
●   Your work product is more commits
●   These are always on a “branch”
●   A branch is just a named commit
●   When you commit, the former branch head
    becomes the parent
Think globally, work locally
●   Your work product is more commits
●   These are always on a “branch”
●   A branch is just a named commit
●   When you commit, the former branch head
    becomes the parent
●   The branch head moves to be the new
    commit
Think globally, work locally
●   Your work product is more commits
●   These are always on a “branch”
●   A branch is just a named commit
●   When you commit, the former branch head
    becomes the parent
●   The branch head moves to be the new
    commit
●   Thus, you’re creating a directed acyclic
    graph, rooted in branch heads
Think globally, work locally
●   Your work product is more commits
●   These are always on a “branch”
●   A branch is just a named commit
●   When you commit, the former branch head
    becomes the parent
●   The branch head moves to be the new
    commit
●   Thus, you’re creating a directed acyclic
    graph, rooted in branch heads
●   A merge is just a commit with multiple
    parents
Typical work flow
Typical work flow
●   Edit edit edit
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
    −   Tells you differences between HEAD, index, and
        working directory
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
    −   Tells you differences between HEAD, index, and
        working directory
●   When you’re ready to commit: git commit
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
    −   Tells you differences between HEAD, index, and
        working directory
●   When you’re ready to commit: git commit
    −   Popped into a text editor (or “-m msg”)
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
    −   Tells you differences between HEAD, index, and
        working directory
●   When you’re ready to commit: git commit
    −   Popped into a text editor (or “-m msg”)
    −   First text line used for “short logs”
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
    −   Tells you differences between HEAD, index, and
        working directory
●   When you’re ready to commit: git commit
    −   Popped into a text editor (or “-m msg”)
    −   First text line used for “short logs”
●   Current branch is moved forward
Typical work flow
●   Edit edit edit
●   git add files/you/have changed/now
    −   This adds the files to the index
    −   “git add .” for adding all interesting files
●   git status
    −   Tells you differences between HEAD, index, and
        working directory
●   When you’re ready to commit: git commit
    −   Popped into a text editor (or “-m msg”)
    −   First text line used for “short logs”
●   Current branch is moved forward
●   And you’re back to more editing
But which branch?
But which branch?
●   Git encourages branching
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
    −   git merge topic-name
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
    −   git merge topic-name
    −   git branch -d topic-name
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
    −   git merge topic-name
    −   git branch -d topic-name
         ●   Permitted only when it’s a subset of HEAD
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
    −   git merge topic-name
    −   git branch -d topic-name
         ●   Permitted only when it’s a subset of HEAD
●   Each individual commit is shown
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
    −   git merge topic-name
    −   git branch -d topic-name
         ●   Permitted only when it’s a subset of HEAD
●   Each individual commit is shown
●   For all work as a single commit:
But which branch?
●   Git encourages branching
    −   A branch is just 41 text bytes!
●   Typical work flow:
    −   Think of something to do
    −   git checkout -b topic-name master
    −   work work work, commit to topic-name
●   When your thing is done:
    −   git checkout master
    −   git merge topic-name
    −   git branch -d topic-name
         ●   Permitted only when it’s a subset of HEAD
●   Each individual commit is shown
●   For all work as a single commit:
    −   git merge --squash --no-commit t; git commit
Working in parallel
Working in parallel
●   You can have multiple topics active:
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
    −   work work work; commit
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
    −   work work work; commit
    −   git checkout topic1; work work; commit
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
    −   work work work; commit
    −   git checkout topic1; work work; commit
●   Decide how to bring them together
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
    −   work work work; commit
    −   git checkout topic1; work work; commit
●   Decide how to bring them together
●   Merge: parallel histories
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
    −   work work work; commit
    −   git checkout topic1; work work; commit
●   Decide how to bring them together
●   Merge: parallel histories
●   Rebase: serial histories
Working in parallel
●   You can have multiple topics active:
    −   git checkout -b topic1 master
    −   work work work; commit; work work; commit
    −   git checkout -b topic2 master
    −   work work work; commit
    −   git checkout topic1; work work; commit
●   Decide how to bring them together
●   Merge: parallel histories
●   Rebase: serial histories
●   Each has pros and cons
The merge
The merge
●   git checkout master
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
●   You need to resolve, and continue:
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
●   You need to resolve, and continue:
    −   git add any/thing/you fixed/now
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
●   You need to resolve, and continue:
    −   git add any/thing/you fixed/now
         ●   or git add .
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
●   You need to resolve, and continue:
    −   git add any/thing/you fixed/now
         ●   or git add .
    −   git commit (describe the merge here)
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
●   You need to resolve, and continue:
    −   git add any/thing/you fixed/now
         ●   or git add .
    −   git commit (describe the merge here)
●   You can also abort:
The merge
●   git checkout master
●   git merge topic1; git branch -d topic1
    −   This should be trivial (“fast forward”) merge
●   git merge topic2
●   Conflicts may arise:
    −   overlapping changes in text edits
    −   files renamed two different ways
●   You need to resolve, and continue:
    −   git add any/thing/you fixed/now
         ●   or git add .
    −   git commit (describe the merge here)
●   You can also abort:
    −   git reset --hard HEAD
The rebase
The rebase
●   Rewrites commits as if they started in a
    different place
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
    −   All changes in topic2 but not in master are
        rewritten as changes to the new master
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
    −   All changes in topic2 but not in master are
        rewritten as changes to the new master
●   May result in merge conflicts:
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
    −   All changes in topic2 but not in master are
        rewritten as changes to the new master
●   May result in merge conflicts:
    −   git rebase --continue or --abort or --skip
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
    −   All changes in topic2 but not in master are
        rewritten as changes to the new master
●   May result in merge conflicts:
    −   git rebase --continue or --abort or --skip
●   git rebase -i (interactive) is helpful
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
    −   All changes in topic2 but not in master are
        rewritten as changes to the new master
●   May result in merge conflicts:
    −   git rebase --continue or --abort or --skip
●   git rebase -i (interactive) is helpful
●   When rebased, merge is a fast forward:
The rebase
●   Rewrites commits as if they started in a
    different place
●   Breaks SHA1s: commits are lost!
    −   Don’t rebase if you’ve published commits!
●   git rebase master topic2
    −   All changes in topic2 but not in master are
        rewritten as changes to the new master
●   May result in merge conflicts:
    −   git rebase --continue or --abort or --skip
●   git rebase -i (interactive) is helpful
●   When rebased, merge is a fast forward:
    −   git checkout master; git merge topic2
Read the history
Read the history
●   git log
Read the history
●   git log
    −   print the changes
Read the history
●   git log
    −   print the changes
●   git log -p
Read the history
●   git log
    −   print the changes
●   git log -p
    −   print the changes, including a diff between
        revisions
Read the history
●   git log
    −   print the changes
●   git log -p
    −   print the changes, including a diff between
        revisions
●   git log --stat
Read the history
●   git log
    −   print the changes
●   git log -p
    −   print the changes, including a diff between
        revisions
●   git log --stat
    −   Summarize the changes with a diffstat
Read the history
●   git log
    −   print the changes
●   git log -p
    −   print the changes, including a diff between
        revisions
●   git log --stat
    −   Summarize the changes with a diffstat
●   git log file1 file2 dir3
Read the history
●   git log
    −   print the changes
●   git log -p
    −   print the changes, including a diff between
        revisions
●   git log --stat
    −   Summarize the changes with a diffstat
●   git log file1 file2 dir3
    −   Show changes only for listed files or subdirs
What’s the difference?
What’s the difference?
●   git diff
What’s the difference?
●   git diff
    −   Diff between index and working tree
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
    −   between HEAD and index
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
    −   between HEAD and index
    −   “git commit” (without -a) makes this empty
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
    −   between HEAD and index
    −   “git commit” (without -a) makes this empty
●   git diff OTHERBRANCH
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
    −   between HEAD and index
    −   “git commit” (without -a) makes this empty
●   git diff OTHERBRANCH
    −   Other branch and working tree
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
    −   between HEAD and index
    −   “git commit” (without -a) makes this empty
●   git diff OTHERBRANCH
    −   Other branch and working tree
●   git diff BRANCH1 BRANCH2
What’s the difference?
●   git diff
    −   Diff between index and working tree
    −   These are things you should “git add”
    −   “git commit -a” will also make this list empty
●   git diff HEAD
    −   Difference between HEAD and working tree
    −   “git commit -a” will make this empty
●   git diff --cached
    −   between HEAD and index
    −   “git commit” (without -a) makes this empty
●   git diff OTHERBRANCH
    −   Other branch and working tree
●   git diff BRANCH1 BRANCH2
    −   Difference between two branch heads
Barking up the tree
Barking up the tree
●   Most commands take “tree-ish” args
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
    −   :path - pick the object from the tree
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
    −   :path - pick the object from the tree
●   Examples:
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
    −   :path - pick the object from the tree
●   Examples:
    −   git diff HEAD^ HEAD
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
    −   :path - pick the object from the tree
●   Examples:
    −   git diff HEAD^ HEAD
         ●   most recent change on current branch
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
    −   :path - pick the object from the tree
●   Examples:
    −   git diff HEAD^ HEAD
         ●   most recent change on current branch
    −   git diff HEAD~3 HEAD
Barking up the tree
●   Most commands take “tree-ish” args
●   SHA1 picks something absolutely
    −   Can be abbreviated if not ambiguous
●   HEAD, some-branch-name, some-tag-
    name, some-origin-name
●   Any of those followed by:
    −   ^n - “the n-th parent of an item” (default 1)
    −   ~n - n ^1’s (so ~3 is ^1^1^1)
    −   :path - pick the object from the tree
●   Examples:
    −   git diff HEAD^ HEAD
         ●   most recent change on current branch
    −   git diff HEAD~3 HEAD
         ●   What damage did last three edits do?
Seeing the changes side by
           side
Seeing the changes side by
               side
●   gitk mytopic origin
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
    −   show everything
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
    −   show everything
●   gitk from..to
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
    −   show everything
●   gitk from..to
    −   Just the changes in “to” that aren’t in “from”
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
    −   show everything
●   gitk from..to
    −   Just the changes in “to” that aren’t in “from”
●   git show-branch mytopic...origin
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
    −   show everything
●   gitk from..to
    −   Just the changes in “to” that aren’t in “from”
●   git show-branch mytopic...origin
    −   Same thing for the Tk-challenged
Seeing the changes side by
               side
●   gitk mytopic origin
    −   Tk widget display of history
    −   Shows changes back to common ancestor
●   gitk --all
    −   show everything
●   gitk from..to
    −   Just the changes in “to” that aren’t in “from”
●   git show-branch mytopic...origin
    −   Same thing for the Tk-challenged
●   See also “qgit”
Playing well with others
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
    −   git checkout master # or whatever branch
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
    −   git checkout master # or whatever branch
    −   git rebase origin/master
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
    −   git checkout master # or whatever branch
    −   git rebase origin/master
●   Or fetch/rebase in one step
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
    −   git checkout master # or whatever branch
    −   git rebase origin/master
●   Or fetch/rebase in one step
    −   git pull --rebase
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
    −   git checkout master # or whatever branch
    −   git rebase origin/master
●   Or fetch/rebase in one step
    −   git pull --rebase
●   To push upstream:
Playing well with others
●   git clone creates “tracking” or “remote”
    branches
●   Typically named “origin/master” etc
●   To share your work, first get up to date:
    −   git fetch (defaults to branches of origin)
●   Now rebase your changes on upstream:
    −   git checkout master # or whatever branch
    −   git rebase origin/master
●   Or fetch/rebase in one step
    −   git pull --rebase
●   To push upstream:
    −   git push
Resetting
Resetting
●   git reset --soft
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
    −   Forces working dir to look like last commit
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
    −   Forces working dir to look like last commit
●   git reset --hard HEAD~3
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
    −   Forces working dir to look like last commit
●   git reset --hard HEAD~3
    −   Tosses most recent 3 commits, and updates the
        work dir to match that
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
    −   Forces working dir to look like last commit
●   git reset --hard HEAD~3
    −   Tosses most recent 3 commits, and updates the
        work dir to match that
    −   Don’t do this if you’ve published: use git revert
        instead
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
    −   Forces working dir to look like last commit
●   git reset --hard HEAD~3
    −   Tosses most recent 3 commits, and updates the
        work dir to match that
    −   Don’t do this if you’ve published: use git revert
        instead
●   git checkout HEAD some/lost/file
Resetting
●   git reset --soft
    −   Makes all files “updated but not checked in”
●   git reset --hard # DANGER
    −   Forces working dir to look like last commit
●   git reset --hard HEAD~3
    −   Tosses most recent 3 commits, and updates the
        work dir to match that
    −   Don’t do this if you’ve published: use git revert
        instead
●   git checkout HEAD some/lost/file
    −   Recover the version of some/lost/file from the
        last commit
Pay no attention to the man
    behind the curtain
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
    −   otherwise, shell glob via fnmatch(3)
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
    −   otherwise, shell glob via fnmatch(3)
    −   Leading / means “the current directory”
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
    −   otherwise, shell glob via fnmatch(3)
    −   Leading / means “the current directory”
●   Checked into the repository and tracked
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
    −   otherwise, shell glob via fnmatch(3)
    −   Leading / means “the current directory”
●   Checked into the repository and tracked
●   Every repository can contain a .git/info/
    exclude
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
    −   otherwise, shell glob via fnmatch(3)
    −   Leading / means “the current directory”
●   Checked into the repository and tracked
●   Every repository can contain a .git/info/
    exclude
●   Both of these work together
Pay no attention to the man
        behind the curtain
●   Every directory can contain a .gitignore
    −   lines starting with “!” mean “not”
    −   lines without “/” are checked against basename
    −   otherwise, shell glob via fnmatch(3)
    −   Leading / means “the current directory”
●   Checked into the repository and tracked
●   Every repository can contain a .git/info/
    exclude
●   Both of these work together
●   But .git/info/exclude won’t be cloned
Configuration
Configuration
●   Many commands have configurations
Configuration
●   Many commands have configurations
●   git config name value
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
●   git config -l
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
●   git config -l
    −   get all values
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
●   git config -l
    −   get all values
●   git config --global name [value]
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
●   git config -l
    −   get all values
●   git config --global name [value]
    −   Same, but with ~/.gitconfig
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
●   git config -l
    −   get all values
●   git config --global name [value]
    −   Same, but with ~/.gitconfig
    −   This applies to all git repos from a user
Configuration
●   Many commands have configurations
●   git config name value
    −   set name to value
    −   name can contain periods for sub-items
    −   can edit manually if you’d prefer
●   git config name
    −   get current value
●   git config -l
    −   get all values
●   git config --global name [value]
    −   Same, but with ~/.gitconfig
    −   This applies to all git repos from a user
●   At a minimum, set user.email and
    user.name for commits
Other useful porcelain
Other useful porcelain
●   git archive: export a tree as a tar/zip
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
●   git cherry-pick: selective merging
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
●   git cherry-pick: selective merging
●   git mv: rename a file/dir with the right
    index manipulations
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
●   git cherry-pick: selective merging
●   git mv: rename a file/dir with the right
    index manipulations
●   git rm: ditto for delete
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
●   git cherry-pick: selective merging
●   git mv: rename a file/dir with the right
    index manipulations
●   git rm: ditto for delete
●   git push: write to an upstream
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
●   git cherry-pick: selective merging
●   git mv: rename a file/dir with the right
    index manipulations
●   git rm: ditto for delete
●   git push: write to an upstream
●   git revert: add a commit that undoes a
    previous commit
Other useful porcelain
●   git archive: export a tree as a tar/zip
●   git bisect: find the offensive commit
●   git cherry-pick: selective merging
●   git mv: rename a file/dir with the right
    index manipulations
●   git rm: ditto for delete
●   git push: write to an upstream
●   git revert: add a commit that undoes a
    previous commit
●   git blame: who wrote this?
For further info
For further info
●   See “Git (software)” in Wikipedia
For further info
●   See “Git (software)” in Wikipedia
●   And the git homepage http://git.or.cz
For further info
●   See “Git (software)” in Wikipedia
●   And the git homepage http://git.or.cz
●   Git wiki at http://git.or.cz/gitwiki
For further info
●   See “Git (software)” in Wikipedia
●   And the git homepage http://git.or.cz
●   Git wiki at http://git.or.cz/gitwiki
●   Get on the mailing list
For further info
●   See “Git (software)” in Wikipedia
●   And the git homepage http://git.or.cz
●   Git wiki at http://git.or.cz/gitwiki
●   Get on the mailing list
    −   Helpful people there
For further info
●   See “Git (software)” in Wikipedia
●   And the git homepage http://git.or.cz
●   Git wiki at http://git.or.cz/gitwiki
●   Get on the mailing list
    −   Helpful people there
    −   You can submit bugs, patches, ideas
For further info
●   See “Git (software)” in Wikipedia
●   And the git homepage http://git.or.cz
●   Git wiki at http://git.or.cz/gitwiki
●   Get on the mailing list
    −   Helpful people there
    −   You can submit bugs, patches, ideas
    −   Find out who else is using git
Introduction to Git
Introduction to Git

Weitere ähnliche Inhalte

Was ist angesagt?

Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started PresentationNap Ramirez
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git: a brief introduction
Git: a brief introductionGit: a brief introduction
Git: a brief introductionRandal Schwartz
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamentalRajesh Kumar
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...Edureka!
 
Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginningJames Aylett
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administrationShawn Doyle
 

Was ist angesagt? (20)

Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git: a brief introduction
Git: a brief introductionGit: a brief introduction
Git: a brief introduction
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git basics
Git basicsGit basics
Git basics
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
 
git and github
git and githubgit and github
git and github
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
 

Andere mochten auch

Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Git 101 Presentation
Git 101 PresentationGit 101 Presentation
Git 101 PresentationScott Chacon
 
A brief introduction to dart
A brief introduction to dartA brief introduction to dart
A brief introduction to dartRandal Schwartz
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideRohit Arora
 

Andere mochten auch (7)

01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Git 101 Presentation
Git 101 PresentationGit 101 Presentation
Git 101 Presentation
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
A brief introduction to dart
A brief introduction to dartA brief introduction to dart
A brief introduction to dart
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guide
 

Ähnlich wie Introduction to Git

Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
Enterprise git
Enterprise gitEnterprise git
Enterprise gitPedro Melo
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysCarlos Taborda
 
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopOpen Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopWong Hoi Sing Edison
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsGorav Singal
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubBigBlueHat
 
Barcamp Macau 2014 - Introduction to GIT
Barcamp Macau 2014 - Introduction to GITBarcamp Macau 2014 - Introduction to GIT
Barcamp Macau 2014 - Introduction to GITWong Hoi Sing Edison
 
Git censored.key
Git censored.keyGit censored.key
Git censored.keymkramer2
 
An introductory guide to GIT
An introductory guide to GITAn introductory guide to GIT
An introductory guide to GITAmith jayasekara
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-trainingEric Guo
 

Ähnlich wie Introduction to Git (20)

Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Enterprise git
Enterprise gitEnterprise git
Enterprise git
 
Git: be social
Git: be socialGit: be social
Git: be social
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anyways
 
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopOpen Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
 
3 Git
3 Git3 Git
3 Git
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
 
Git
GitGit
Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
Git SVN Migrate Reasons
Git SVN Migrate ReasonsGit SVN Migrate Reasons
Git SVN Migrate Reasons
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Barcamp Macau 2014 - Introduction to GIT
Barcamp Macau 2014 - Introduction to GITBarcamp Macau 2014 - Introduction to GIT
Barcamp Macau 2014 - Introduction to GIT
 
Git censored.key
Git censored.keyGit censored.key
Git censored.key
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
An introductory guide to GIT
An introductory guide to GITAn introductory guide to GIT
An introductory guide to GIT
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-training
 

Mehr von Randal Schwartz

Native mobile application development with Flutter (Dart)
Native mobile application development with Flutter (Dart)Native mobile application development with Flutter (Dart)
Native mobile application development with Flutter (Dart)Randal Schwartz
 
Intro to git (one hour version)
Intro to git (one hour version)Intro to git (one hour version)
Intro to git (one hour version)Randal Schwartz
 

Mehr von Randal Schwartz (7)

Why Flutter.pdf
Why Flutter.pdfWhy Flutter.pdf
Why Flutter.pdf
 
Native mobile application development with Flutter (Dart)
Native mobile application development with Flutter (Dart)Native mobile application development with Flutter (Dart)
Native mobile application development with Flutter (Dart)
 
Perl best practices v4
Perl best practices v4Perl best practices v4
Perl best practices v4
 
My half life with perl
My half life with perlMy half life with perl
My half life with perl
 
Intro to git (one hour version)
Intro to git (one hour version)Intro to git (one hour version)
Intro to git (one hour version)
 
Testing scripts
Testing scriptsTesting scripts
Testing scripts
 
Forget The ORM!
Forget The ORM!Forget The ORM!
Forget The ORM!
 

Kürzlich hochgeladen

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 

Kürzlich hochgeladen (20)

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 

Introduction to Git

  • 1. Git: a brief introduction Randal Schwartz merlyn@stonehenge.com http://www.stonehenge.com/merlyn/ Version 3.01 on 12-Jan-2010
  • 3. Disclaimer ● I've been tracking git since it was created
  • 4. Disclaimer ● I've been tracking git since it was created ● I've used git on small projects
  • 5. Disclaimer ● I've been tracking git since it was created ● I've used git on small projects ● I've used other systems on small and large projects
  • 6. Disclaimer ● I've been tracking git since it was created ● I've used git on small projects ● I've used other systems on small and large projects ● I've read a lot of people talk about git on the mailing list
  • 7. Disclaimer ● I've been tracking git since it was created ● I've used git on small projects ● I've used other systems on small and large projects ● I've read a lot of people talk about git on the mailing list ● I've even provided some patches to git, and suggestions for user interface changes
  • 8. Disclaimer ● I've been tracking git since it was created ● I've used git on small projects ● I've used other systems on small and large projects ● I've read a lot of people talk about git on the mailing list ● I've even provided some patches to git, and suggestions for user interface changes ● I have worked on small and medium teams with git
  • 9. Disclaimer ● I've been tracking git since it was created ● I've used git on small projects ● I've used other systems on small and large projects ● I've read a lot of people talk about git on the mailing list ● I've even provided some patches to git, and suggestions for user interface changes ● I have worked on small and medium teams with git ● But not large ones
  • 11. What is git? ● Git manages changes to a tree of files over time
  • 12. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for:
  • 13. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development
  • 14. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets
  • 15. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges
  • 16. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches
  • 17. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches − Being very fast
  • 18. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches − Being very fast − Being robust
  • 19. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches − Being very fast − Being robust ● Git is not optimized for:
  • 20. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches − Being very fast − Being robust ● Git is not optimized for: − Tracking file permissions and ownership
  • 21. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches − Being very fast − Being robust ● Git is not optimized for: − Tracking file permissions and ownership − Tracking individual files with separate history
  • 22. What is git? ● Git manages changes to a tree of files over time ● Git is optimized for: − Distributed development − Large file sets − Complex merges − Making trial branches − Being very fast − Being robust ● Git is not optimized for: − Tracking file permissions and ownership − Tracking individual files with separate history − Making things painful
  • 24. Why git? ● Essential to Linux kernel development
  • 25. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable”
  • 26. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit”
  • 27. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can:
  • 28. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can: − Clone the tree
  • 29. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can: − Clone the tree − Make and test local changes
  • 30. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can: − Clone the tree − Make and test local changes − Submit the changes as patches via mail
  • 31. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can: − Clone the tree − Make and test local changes − Submit the changes as patches via mail − OR submit them as a published repository
  • 32. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can: − Clone the tree − Make and test local changes − Submit the changes as patches via mail − OR submit them as a published repository − Track the upstream to revise if needed
  • 33. Why git? ● Essential to Linux kernel development ● Created as a replacement when BitKeeper suddenly became “unavailable” ● Everybody has a “commit bit” ● Anyone can: − Clone the tree − Make and test local changes − Submit the changes as patches via mail − OR submit them as a published repository − Track the upstream to revise if needed ● Kernel.org is just a convenient public watering hole
  • 34. How does git do it?
  • 35. How does git do it? ● Universal public identifiers
  • 36. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992”
  • 37. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport
  • 38. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP
  • 39. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH
  • 40. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT
  • 41. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT ● Efficient object storage
  • 42. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT ● Efficient object storage ● Everyone has entire repo (disk is cheap)
  • 43. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT ● Efficient object storage ● Everyone has entire repo (disk is cheap) ● Easy branching and merging
  • 44. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT ● Efficient object storage ● Everyone has entire repo (disk is cheap) ● Easy branching and merging − Common ancestors are computable
  • 45. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT ● Efficient object storage ● Everyone has entire repo (disk is cheap) ● Easy branching and merging − Common ancestors are computable ● Patches (and repo updates) can be transported or mailed
  • 46. How does git do it? ● Universal public identifiers − None of the SVK “my @245 is your @992” ● Multi-protocol transport − HTTP − SSH − GIT ● Efficient object storage ● Everyone has entire repo (disk is cheap) ● Easy branching and merging − Common ancestors are computable ● Patches (and repo updates) can be transported or mailed ● Binary “patches” are supported
  • 47. The SHA1 is King
  • 48. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it
  • 49. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of:
  • 50. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file)
  • 51. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees)
  • 52. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits:
  • 53. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree
  • 54. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits
  • 55. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits ● Plus a message about why
  • 56. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits ● Plus a message about why − Tags:
  • 57. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits ● Plus a message about why − Tags: ● An object (usually a commit)
  • 58. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits ● Plus a message about why − Tags: ● An object (usually a commit) ● Plus a subject
  • 59. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits ● Plus a message about why − Tags: ● An object (usually a commit) ● Plus a subject ● Plus an optional payload to sign it off
  • 60. The SHA1 is King ● Every “object” has a SHA1 to uniquely identify it ● “objects” consist of: − Blobs (the contents of a file) − Trees (directories of blobs or other trees) − Commits: ● A tree ● Plus zero or more parent commits ● Plus a message about why − Tags: ● An object (usually a commit) ● Plus a subject ● Plus an optional payload to sign it off ● Plus an optional gpg signature
  • 61. Objects live in the repo
  • 62. Objects live in the repo ● Git efficiently creates new objects
  • 63. Objects live in the repo ● Git efficiently creates new objects ● Objects are generally added, not destroyed
  • 64. Objects live in the repo ● Git efficiently creates new objects ● Objects are generally added, not destroyed ● Unreferenced objects (deleted branch, added but not committed, etc) can be garbage collected
  • 65. Objects live in the repo ● Git efficiently creates new objects ● Objects are generally added, not destroyed ● Unreferenced objects (deleted branch, added but not committed, etc) can be garbage collected ● Objects start “loose”, but can be “packed” for filesystem efficiency
  • 66. Objects live in the repo ● Git efficiently creates new objects ● Objects are generally added, not destroyed ● Unreferenced objects (deleted branch, added but not committed, etc) can be garbage collected ● Objects start “loose”, but can be “packed” for filesystem efficiency ● “Packs” often represent objects as deltas for space efficiency
  • 67. Objects live in the repo ● Git efficiently creates new objects ● Objects are generally added, not destroyed ● Unreferenced objects (deleted branch, added but not committed, etc) can be garbage collected ● Objects start “loose”, but can be “packed” for filesystem efficiency ● “Packs” often represent objects as deltas for space efficiency ● “Packs” are also created for transfer between repositories
  • 69. Commits rule the repo ● One or more commits form the head of object chains
  • 70. Commits rule the repo ● One or more commits form the head of object chains ● Typically one head called “master”
  • 71. Commits rule the repo ● One or more commits form the head of object chains ● Typically one head called “master” ● Others can be made at will (“branches”)
  • 72. Commits rule the repo ● One or more commits form the head of object chains ● Typically one head called “master” ● Others can be made at will (“branches”) ● All reachable repo objects are accessed from these head commits
  • 73. Commits rule the repo ● One or more commits form the head of object chains ● Typically one head called “master” ● Others can be made at will (“branches”) ● All reachable repo objects are accessed from these head commits − Chase down the tree object to get to directories and files as they existed at this commit time
  • 74. Commits rule the repo ● One or more commits form the head of object chains ● Typically one head called “master” ● Others can be made at will (“branches”) ● All reachable repo objects are accessed from these head commits − Chase down the tree object to get to directories and files as they existed at this commit time − Chase down the parent objects to get to earlier commits and their respective trees
  • 75. Commits rule the repo ● One or more commits form the head of object chains ● Typically one head called “master” ● Others can be made at will (“branches”) ● All reachable repo objects are accessed from these head commits − Chase down the tree object to get to directories and files as they existed at this commit time − Chase down the parent objects to get to earlier commits and their respective trees ● Usually one commit in the repo that has no parent commit
  • 76. Mapping objects to a file tree
  • 77. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level
  • 78. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly)
  • 79. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains:
  • 80. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style)
  • 81. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository
  • 82. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository − refs/heads/* – branches (like “master”)
  • 83. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository − refs/heads/* – branches (like “master”) − refs/tags/* - tags
  • 84. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository − refs/heads/* – branches (like “master”) − refs/tags/* - tags − logs/* - logs
  • 85. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository − refs/heads/* – branches (like “master”) − refs/tags/* - tags − logs/* - logs − refs/remotes/* - tracking others
  • 86. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository − refs/heads/* – branches (like “master”) − refs/tags/* - tags − logs/* - logs − refs/remotes/* - tracking others − index – the “index cache” (described shortly)
  • 87. Mapping objects to a file tree ● A “working tree” has a “.git” dir at the top level ● Unlike CVS, SVN: no pollution of deeper directories (“grep -r” friendly) ● The .git dir contains: − config – Configuration file (.ini style) − objects/* – The object repository − refs/heads/* – branches (like “master”) − refs/tags/* - tags − logs/* - logs − refs/remotes/* - tracking others − index – the “index cache” (described shortly) − HEAD – points to one of the branches (the “current branch”, where commits go)
  • 88. The index (or “cache”)
  • 89. The index (or “cache”) ● A directory of blob objects
  • 90. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit”
  • 91. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content
  • 92. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object.
  • 93. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object. ● Diff between HEAD and index:
  • 94. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object. ● Diff between HEAD and index: − changed things not yet committed
  • 95. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object. ● Diff between HEAD and index: − changed things not yet committed ● Diff between index and working dir:
  • 96. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object. ● Diff between HEAD and index: − changed things not yet committed ● Diff between index and working dir: − changed things not yet added
  • 97. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object. ● Diff between HEAD and index: − changed things not yet committed ● Diff between index and working dir: − changed things not yet added − untracked things
  • 98. The index (or “cache”) ● A directory of blob objects ● Represents the “next commit” ● “Add files” to put them in the index, including current content ● “Commit” takes the current index and makes it a real commit object. ● Diff between HEAD and index: − changed things not yet committed ● Diff between index and working dir: − changed things not yet added − untracked things ● Index gets interesting during a merge
  • 99. The great renaming controversy
  • 100. The great renaming controversy ● Git doesn’t record explicit renaming
  • 101. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it
  • 102. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it ● Exact renaming can be determined by SHA1 comparisons
  • 103. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it ● Exact renaming can be determined by SHA1 comparisons ● Copy-paste-edits can be detected by ad- hoc “similarity” rules for logs
  • 104. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it ● Exact renaming can be determined by SHA1 comparisons ● Copy-paste-edits can be detected by ad- hoc “similarity” rules for logs ● In general the computer can find these far easier than you can
  • 105. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it ● Exact renaming can be determined by SHA1 comparisons ● Copy-paste-edits can be detected by ad- hoc “similarity” rules for logs ● In general the computer can find these far easier than you can ● If you make it explicit, it will be wrong sometimes
  • 106. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it ● Exact renaming can be determined by SHA1 comparisons ● Copy-paste-edits can be detected by ad- hoc “similarity” rules for logs ● In general the computer can find these far easier than you can ● If you make it explicit, it will be wrong sometimes ● Being wrong breaks merges
  • 107. The great renaming controversy ● Git doesn’t record explicit renaming ● Nor expect you to declare it ● Exact renaming can be determined by SHA1 comparisons ● Copy-paste-edits can be detected by ad- hoc “similarity” rules for logs ● In general the computer can find these far easier than you can ● If you make it explicit, it will be wrong sometimes ● Being wrong breaks merges ● Even being right will break some merges!
  • 108. Git speaks and listens
  • 109. Git speaks and listens ● Many protocols to transfer git data between repositories
  • 110. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files
  • 111. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has:
  • 112. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS
  • 113. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS − import/export with SVN
  • 114. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS − import/export with SVN − import from Arch
  • 115. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS − import/export with SVN − import from Arch ● I use CVS/SVN import to have entire history of a project at 30K feet
  • 116. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS − import/export with SVN − import from Arch ● I use CVS/SVN import to have entire history of a project at 30K feet ● Third party solutions handle others
  • 117. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS − import/export with SVN − import from Arch ● I use CVS/SVN import to have entire history of a project at 30K feet ● Third party solutions handle others ● Git core also includes cvs-server
  • 118. Git speaks and listens ● Many protocols to transfer git data between repositories − rsync, http, https, git, ssh, local files ● In the core, git also has: − import/export with CVS − import/export with SVN − import from Arch ● I use CVS/SVN import to have entire history of a project at 30K feet ● Third party solutions handle others ● Git core also includes cvs-server − A git repository can act like a CVS repository for legacy clients or humans
  • 120. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/
  • 121. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/ ● RPMs and Debian packages also exist
  • 122. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/ ● RPMs and Debian packages also exist ● Once you’ve bootstrapped git, git-clone the git-developer archive
  • 123. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/ ● RPMs and Debian packages also exist ● Once you’ve bootstrapped git, git-clone the git-developer archive − git-clone git://git.kernel.org/pub/scm/git/ git.git
  • 124. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/ ● RPMs and Debian packages also exist ● Once you’ve bootstrapped git, git-clone the git-developer archive − git-clone git://git.kernel.org/pub/scm/git/ git.git ● Rebuild once a week or so
  • 125. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/ ● RPMs and Debian packages also exist ● Once you’ve bootstrapped git, git-clone the git-developer archive − git-clone git://git.kernel.org/pub/scm/git/ git.git ● Rebuild once a week or so ● Maintenance releases are very stable
  • 126. Getting git ● Get the latest “git-*.tar.gz” from http:// www.kernel.org/pub/software/scm/git/ ● RPMs and Debian packages also exist ● Once you’ve bootstrapped git, git-clone the git-developer archive − git-clone git://git.kernel.org/pub/scm/git/ git.git ● Rebuild once a week or so ● Maintenance releases are very stable ● I install mine “prefix=/opt/git”, and add /opt/git/bin to my PATH
  • 128. Git commands ● All git commands start with “git”
  • 129. Git commands ● All git commands start with “git” ● “git MUMBLE-FOO bar” has also been written as “git-MUMBLE-FOO bar”
  • 130. Git commands ● All git commands start with “git” ● “git MUMBLE-FOO bar” has also been written as “git-MUMBLE-FOO bar” ● This allows a single entry “git” to be added to the /usr/local/bin path
  • 131. Git commands ● All git commands start with “git” ● “git MUMBLE-FOO bar” has also been written as “git-MUMBLE-FOO bar” ● This allows a single entry “git” to be added to the /usr/local/bin path ● This works for internal calls as well
  • 132. Git commands ● All git commands start with “git” ● “git MUMBLE-FOO bar” has also been written as “git-MUMBLE-FOO bar” ● This allows a single entry “git” to be added to the /usr/local/bin path ● This works for internal calls as well ● The manpages are still under “git-MUMBLE- FOO”, so you have to know the convention either way
  • 133. Git commands ● All git commands start with “git” ● “git MUMBLE-FOO bar” has also been written as “git-MUMBLE-FOO bar” ● This allows a single entry “git” to be added to the /usr/local/bin path ● This works for internal calls as well ● The manpages are still under “git-MUMBLE- FOO”, so you have to know the convention either way − Unless you use “git help MUMBLE-FOO”
  • 134. Git commands ● All git commands start with “git” ● “git MUMBLE-FOO bar” has also been written as “git-MUMBLE-FOO bar” ● This allows a single entry “git” to be added to the /usr/local/bin path ● This works for internal calls as well ● The manpages are still under “git-MUMBLE- FOO”, so you have to know the convention either way − Unless you use “git help MUMBLE-FOO” − Or “git MUMBLE-FOO --help”
  • 135. “The Internet is just a series of tubes”
  • 136. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing”
  • 137. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain”
  • 138. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui)
  • 139. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui) ● We’ll stick with the git porcelain in the rest of this talk, unless otherwise noted
  • 140. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui) ● We’ll stick with the git porcelain in the rest of this talk, unless otherwise noted ● Other porcelain exists:
  • 141. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui) ● We’ll stick with the git porcelain in the rest of this talk, unless otherwise noted ● Other porcelain exists: − StGit (“stacked git”)
  • 142. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui) ● We’ll stick with the git porcelain in the rest of this talk, unless otherwise noted ● Other porcelain exists: − StGit (“stacked git”) − guilt
  • 143. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui) ● We’ll stick with the git porcelain in the rest of this talk, unless otherwise noted ● Other porcelain exists: − StGit (“stacked git”) − guilt − tig (curses-based viewer)
  • 144. “The Internet is just a series of tubes” ● Low-level git operations are called “plumbing” ● Higher level actions are called “porcelain” ● The git distro includes git plumbing and git porcelain (git-gui) ● We’ll stick with the git porcelain in the rest of this talk, unless otherwise noted ● Other porcelain exists: − StGit (“stacked git”) − guilt − tig (curses-based viewer) − qgit
  • 146. Creating a repo ● git-init
  • 147. Creating a repo ● git-init − Creates a .git in the current dir
  • 148. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore
  • 149. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!)
  • 150. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit
  • 151. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master”
  • 152. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master”
  • 153. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master” ● git-clone REMOTESPEC
  • 154. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master” ● git-clone REMOTESPEC − Creates a git repo from an existing repo
  • 155. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master” ● git-clone REMOTESPEC − Creates a git repo from an existing repo − Generally creates a subdirectory
  • 156. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master” ● git-clone REMOTESPEC − Creates a git repo from an existing repo − Generally creates a subdirectory − Your workfiles and .git are in there
  • 157. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master” ● git-clone REMOTESPEC − Creates a git repo from an existing repo − Generally creates a subdirectory − Your workfiles and .git are in there − All remote branches are “tracked”
  • 158. Creating a repo ● git-init − Creates a .git in the current dir − Optional: edit .gitignore − “git-add .” to add all files (except .git!) − Then “git commit” for the initial commit − Creates a branch named “master” − HEAD points at “master” ● git-clone REMOTESPEC − Creates a git repo from an existing repo − Generally creates a subdirectory − Your workfiles and .git are in there − All remote branches are “tracked” − Remote “HEAD” branch checked out as your initial “master” branch as well
  • 160. Think globally, work locally ● Your work product is more commits
  • 161. Think globally, work locally ● Your work product is more commits ● These are always on a “branch”
  • 162. Think globally, work locally ● Your work product is more commits ● These are always on a “branch” ● A branch is just a named commit
  • 163. Think globally, work locally ● Your work product is more commits ● These are always on a “branch” ● A branch is just a named commit ● When you commit, the former branch head becomes the parent
  • 164. Think globally, work locally ● Your work product is more commits ● These are always on a “branch” ● A branch is just a named commit ● When you commit, the former branch head becomes the parent ● The branch head moves to be the new commit
  • 165. Think globally, work locally ● Your work product is more commits ● These are always on a “branch” ● A branch is just a named commit ● When you commit, the former branch head becomes the parent ● The branch head moves to be the new commit ● Thus, you’re creating a directed acyclic graph, rooted in branch heads
  • 166. Think globally, work locally ● Your work product is more commits ● These are always on a “branch” ● A branch is just a named commit ● When you commit, the former branch head becomes the parent ● The branch head moves to be the new commit ● Thus, you’re creating a directed acyclic graph, rooted in branch heads ● A merge is just a commit with multiple parents
  • 168. Typical work flow ● Edit edit edit
  • 169. Typical work flow ● Edit edit edit ● git add files/you/have changed/now
  • 170. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index
  • 171. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files
  • 172. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status
  • 173. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status − Tells you differences between HEAD, index, and working directory
  • 174. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status − Tells you differences between HEAD, index, and working directory ● When you’re ready to commit: git commit
  • 175. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status − Tells you differences between HEAD, index, and working directory ● When you’re ready to commit: git commit − Popped into a text editor (or “-m msg”)
  • 176. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status − Tells you differences between HEAD, index, and working directory ● When you’re ready to commit: git commit − Popped into a text editor (or “-m msg”) − First text line used for “short logs”
  • 177. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status − Tells you differences between HEAD, index, and working directory ● When you’re ready to commit: git commit − Popped into a text editor (or “-m msg”) − First text line used for “short logs” ● Current branch is moved forward
  • 178. Typical work flow ● Edit edit edit ● git add files/you/have changed/now − This adds the files to the index − “git add .” for adding all interesting files ● git status − Tells you differences between HEAD, index, and working directory ● When you’re ready to commit: git commit − Popped into a text editor (or “-m msg”) − First text line used for “short logs” ● Current branch is moved forward ● And you’re back to more editing
  • 180. But which branch? ● Git encourages branching
  • 181. But which branch? ● Git encourages branching − A branch is just 41 text bytes!
  • 182. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow:
  • 183. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do
  • 184. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master
  • 185. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name
  • 186. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done:
  • 187. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master
  • 188. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master − git merge topic-name
  • 189. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master − git merge topic-name − git branch -d topic-name
  • 190. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master − git merge topic-name − git branch -d topic-name ● Permitted only when it’s a subset of HEAD
  • 191. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master − git merge topic-name − git branch -d topic-name ● Permitted only when it’s a subset of HEAD ● Each individual commit is shown
  • 192. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master − git merge topic-name − git branch -d topic-name ● Permitted only when it’s a subset of HEAD ● Each individual commit is shown ● For all work as a single commit:
  • 193. But which branch? ● Git encourages branching − A branch is just 41 text bytes! ● Typical work flow: − Think of something to do − git checkout -b topic-name master − work work work, commit to topic-name ● When your thing is done: − git checkout master − git merge topic-name − git branch -d topic-name ● Permitted only when it’s a subset of HEAD ● Each individual commit is shown ● For all work as a single commit: − git merge --squash --no-commit t; git commit
  • 195. Working in parallel ● You can have multiple topics active:
  • 196. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master
  • 197. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit
  • 198. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master
  • 199. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master − work work work; commit
  • 200. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master − work work work; commit − git checkout topic1; work work; commit
  • 201. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master − work work work; commit − git checkout topic1; work work; commit ● Decide how to bring them together
  • 202. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master − work work work; commit − git checkout topic1; work work; commit ● Decide how to bring them together ● Merge: parallel histories
  • 203. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master − work work work; commit − git checkout topic1; work work; commit ● Decide how to bring them together ● Merge: parallel histories ● Rebase: serial histories
  • 204. Working in parallel ● You can have multiple topics active: − git checkout -b topic1 master − work work work; commit; work work; commit − git checkout -b topic2 master − work work work; commit − git checkout topic1; work work; commit ● Decide how to bring them together ● Merge: parallel histories ● Rebase: serial histories ● Each has pros and cons
  • 206. The merge ● git checkout master
  • 207. The merge ● git checkout master ● git merge topic1; git branch -d topic1
  • 208. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge
  • 209. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2
  • 210. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise:
  • 211. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits
  • 212. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways
  • 213. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways ● You need to resolve, and continue:
  • 214. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways ● You need to resolve, and continue: − git add any/thing/you fixed/now
  • 215. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways ● You need to resolve, and continue: − git add any/thing/you fixed/now ● or git add .
  • 216. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways ● You need to resolve, and continue: − git add any/thing/you fixed/now ● or git add . − git commit (describe the merge here)
  • 217. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways ● You need to resolve, and continue: − git add any/thing/you fixed/now ● or git add . − git commit (describe the merge here) ● You can also abort:
  • 218. The merge ● git checkout master ● git merge topic1; git branch -d topic1 − This should be trivial (“fast forward”) merge ● git merge topic2 ● Conflicts may arise: − overlapping changes in text edits − files renamed two different ways ● You need to resolve, and continue: − git add any/thing/you fixed/now ● or git add . − git commit (describe the merge here) ● You can also abort: − git reset --hard HEAD
  • 220. The rebase ● Rewrites commits as if they started in a different place
  • 221. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost!
  • 222. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits!
  • 223. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2
  • 224. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2 − All changes in topic2 but not in master are rewritten as changes to the new master
  • 225. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2 − All changes in topic2 but not in master are rewritten as changes to the new master ● May result in merge conflicts:
  • 226. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2 − All changes in topic2 but not in master are rewritten as changes to the new master ● May result in merge conflicts: − git rebase --continue or --abort or --skip
  • 227. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2 − All changes in topic2 but not in master are rewritten as changes to the new master ● May result in merge conflicts: − git rebase --continue or --abort or --skip ● git rebase -i (interactive) is helpful
  • 228. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2 − All changes in topic2 but not in master are rewritten as changes to the new master ● May result in merge conflicts: − git rebase --continue or --abort or --skip ● git rebase -i (interactive) is helpful ● When rebased, merge is a fast forward:
  • 229. The rebase ● Rewrites commits as if they started in a different place ● Breaks SHA1s: commits are lost! − Don’t rebase if you’ve published commits! ● git rebase master topic2 − All changes in topic2 but not in master are rewritten as changes to the new master ● May result in merge conflicts: − git rebase --continue or --abort or --skip ● git rebase -i (interactive) is helpful ● When rebased, merge is a fast forward: − git checkout master; git merge topic2
  • 232. Read the history ● git log − print the changes
  • 233. Read the history ● git log − print the changes ● git log -p
  • 234. Read the history ● git log − print the changes ● git log -p − print the changes, including a diff between revisions
  • 235. Read the history ● git log − print the changes ● git log -p − print the changes, including a diff between revisions ● git log --stat
  • 236. Read the history ● git log − print the changes ● git log -p − print the changes, including a diff between revisions ● git log --stat − Summarize the changes with a diffstat
  • 237. Read the history ● git log − print the changes ● git log -p − print the changes, including a diff between revisions ● git log --stat − Summarize the changes with a diffstat ● git log file1 file2 dir3
  • 238. Read the history ● git log − print the changes ● git log -p − print the changes, including a diff between revisions ● git log --stat − Summarize the changes with a diffstat ● git log file1 file2 dir3 − Show changes only for listed files or subdirs
  • 241. What’s the difference? ● git diff − Diff between index and working tree
  • 242. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add”
  • 243. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty
  • 244. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD
  • 245. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree
  • 246. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty
  • 247. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached
  • 248. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached − between HEAD and index
  • 249. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached − between HEAD and index − “git commit” (without -a) makes this empty
  • 250. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached − between HEAD and index − “git commit” (without -a) makes this empty ● git diff OTHERBRANCH
  • 251. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached − between HEAD and index − “git commit” (without -a) makes this empty ● git diff OTHERBRANCH − Other branch and working tree
  • 252. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached − between HEAD and index − “git commit” (without -a) makes this empty ● git diff OTHERBRANCH − Other branch and working tree ● git diff BRANCH1 BRANCH2
  • 253. What’s the difference? ● git diff − Diff between index and working tree − These are things you should “git add” − “git commit -a” will also make this list empty ● git diff HEAD − Difference between HEAD and working tree − “git commit -a” will make this empty ● git diff --cached − between HEAD and index − “git commit” (without -a) makes this empty ● git diff OTHERBRANCH − Other branch and working tree ● git diff BRANCH1 BRANCH2 − Difference between two branch heads
  • 254. Barking up the tree
  • 255. Barking up the tree ● Most commands take “tree-ish” args
  • 256. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely
  • 257. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous
  • 258. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name
  • 259. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by:
  • 260. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1)
  • 261. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1)
  • 262. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1) − :path - pick the object from the tree
  • 263. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1) − :path - pick the object from the tree ● Examples:
  • 264. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1) − :path - pick the object from the tree ● Examples: − git diff HEAD^ HEAD
  • 265. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1) − :path - pick the object from the tree ● Examples: − git diff HEAD^ HEAD ● most recent change on current branch
  • 266. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1) − :path - pick the object from the tree ● Examples: − git diff HEAD^ HEAD ● most recent change on current branch − git diff HEAD~3 HEAD
  • 267. Barking up the tree ● Most commands take “tree-ish” args ● SHA1 picks something absolutely − Can be abbreviated if not ambiguous ● HEAD, some-branch-name, some-tag- name, some-origin-name ● Any of those followed by: − ^n - “the n-th parent of an item” (default 1) − ~n - n ^1’s (so ~3 is ^1^1^1) − :path - pick the object from the tree ● Examples: − git diff HEAD^ HEAD ● most recent change on current branch − git diff HEAD~3 HEAD ● What damage did last three edits do?
  • 268. Seeing the changes side by side
  • 269. Seeing the changes side by side ● gitk mytopic origin
  • 270. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history
  • 271. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor
  • 272. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all
  • 273. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all − show everything
  • 274. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all − show everything ● gitk from..to
  • 275. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all − show everything ● gitk from..to − Just the changes in “to” that aren’t in “from”
  • 276. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all − show everything ● gitk from..to − Just the changes in “to” that aren’t in “from” ● git show-branch mytopic...origin
  • 277. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all − show everything ● gitk from..to − Just the changes in “to” that aren’t in “from” ● git show-branch mytopic...origin − Same thing for the Tk-challenged
  • 278. Seeing the changes side by side ● gitk mytopic origin − Tk widget display of history − Shows changes back to common ancestor ● gitk --all − show everything ● gitk from..to − Just the changes in “to” that aren’t in “from” ● git show-branch mytopic...origin − Same thing for the Tk-challenged ● See also “qgit”
  • 279. Playing well with others
  • 280. Playing well with others ● git clone creates “tracking” or “remote” branches
  • 281. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc
  • 282. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date:
  • 283. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin)
  • 284. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream:
  • 285. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream: − git checkout master # or whatever branch
  • 286. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream: − git checkout master # or whatever branch − git rebase origin/master
  • 287. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream: − git checkout master # or whatever branch − git rebase origin/master ● Or fetch/rebase in one step
  • 288. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream: − git checkout master # or whatever branch − git rebase origin/master ● Or fetch/rebase in one step − git pull --rebase
  • 289. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream: − git checkout master # or whatever branch − git rebase origin/master ● Or fetch/rebase in one step − git pull --rebase ● To push upstream:
  • 290. Playing well with others ● git clone creates “tracking” or “remote” branches ● Typically named “origin/master” etc ● To share your work, first get up to date: − git fetch (defaults to branches of origin) ● Now rebase your changes on upstream: − git checkout master # or whatever branch − git rebase origin/master ● Or fetch/rebase in one step − git pull --rebase ● To push upstream: − git push
  • 292. Resetting ● git reset --soft
  • 293. Resetting ● git reset --soft − Makes all files “updated but not checked in”
  • 294. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER
  • 295. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER − Forces working dir to look like last commit
  • 296. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER − Forces working dir to look like last commit ● git reset --hard HEAD~3
  • 297. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER − Forces working dir to look like last commit ● git reset --hard HEAD~3 − Tosses most recent 3 commits, and updates the work dir to match that
  • 298. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER − Forces working dir to look like last commit ● git reset --hard HEAD~3 − Tosses most recent 3 commits, and updates the work dir to match that − Don’t do this if you’ve published: use git revert instead
  • 299. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER − Forces working dir to look like last commit ● git reset --hard HEAD~3 − Tosses most recent 3 commits, and updates the work dir to match that − Don’t do this if you’ve published: use git revert instead ● git checkout HEAD some/lost/file
  • 300. Resetting ● git reset --soft − Makes all files “updated but not checked in” ● git reset --hard # DANGER − Forces working dir to look like last commit ● git reset --hard HEAD~3 − Tosses most recent 3 commits, and updates the work dir to match that − Don’t do this if you’ve published: use git revert instead ● git checkout HEAD some/lost/file − Recover the version of some/lost/file from the last commit
  • 301. Pay no attention to the man behind the curtain
  • 302. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore
  • 303. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not”
  • 304. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename
  • 305. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename − otherwise, shell glob via fnmatch(3)
  • 306. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename − otherwise, shell glob via fnmatch(3) − Leading / means “the current directory”
  • 307. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename − otherwise, shell glob via fnmatch(3) − Leading / means “the current directory” ● Checked into the repository and tracked
  • 308. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename − otherwise, shell glob via fnmatch(3) − Leading / means “the current directory” ● Checked into the repository and tracked ● Every repository can contain a .git/info/ exclude
  • 309. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename − otherwise, shell glob via fnmatch(3) − Leading / means “the current directory” ● Checked into the repository and tracked ● Every repository can contain a .git/info/ exclude ● Both of these work together
  • 310. Pay no attention to the man behind the curtain ● Every directory can contain a .gitignore − lines starting with “!” mean “not” − lines without “/” are checked against basename − otherwise, shell glob via fnmatch(3) − Leading / means “the current directory” ● Checked into the repository and tracked ● Every repository can contain a .git/info/ exclude ● Both of these work together ● But .git/info/exclude won’t be cloned
  • 312. Configuration ● Many commands have configurations
  • 313. Configuration ● Many commands have configurations ● git config name value
  • 314. Configuration ● Many commands have configurations ● git config name value − set name to value
  • 315. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items
  • 316. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer
  • 317. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name
  • 318. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value
  • 319. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value ● git config -l
  • 320. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value ● git config -l − get all values
  • 321. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value ● git config -l − get all values ● git config --global name [value]
  • 322. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value ● git config -l − get all values ● git config --global name [value] − Same, but with ~/.gitconfig
  • 323. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value ● git config -l − get all values ● git config --global name [value] − Same, but with ~/.gitconfig − This applies to all git repos from a user
  • 324. Configuration ● Many commands have configurations ● git config name value − set name to value − name can contain periods for sub-items − can edit manually if you’d prefer ● git config name − get current value ● git config -l − get all values ● git config --global name [value] − Same, but with ~/.gitconfig − This applies to all git repos from a user ● At a minimum, set user.email and user.name for commits
  • 326. Other useful porcelain ● git archive: export a tree as a tar/zip
  • 327. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit
  • 328. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit ● git cherry-pick: selective merging
  • 329. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit ● git cherry-pick: selective merging ● git mv: rename a file/dir with the right index manipulations
  • 330. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit ● git cherry-pick: selective merging ● git mv: rename a file/dir with the right index manipulations ● git rm: ditto for delete
  • 331. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit ● git cherry-pick: selective merging ● git mv: rename a file/dir with the right index manipulations ● git rm: ditto for delete ● git push: write to an upstream
  • 332. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit ● git cherry-pick: selective merging ● git mv: rename a file/dir with the right index manipulations ● git rm: ditto for delete ● git push: write to an upstream ● git revert: add a commit that undoes a previous commit
  • 333. Other useful porcelain ● git archive: export a tree as a tar/zip ● git bisect: find the offensive commit ● git cherry-pick: selective merging ● git mv: rename a file/dir with the right index manipulations ● git rm: ditto for delete ● git push: write to an upstream ● git revert: add a commit that undoes a previous commit ● git blame: who wrote this?
  • 335. For further info ● See “Git (software)” in Wikipedia
  • 336. For further info ● See “Git (software)” in Wikipedia ● And the git homepage http://git.or.cz
  • 337. For further info ● See “Git (software)” in Wikipedia ● And the git homepage http://git.or.cz ● Git wiki at http://git.or.cz/gitwiki
  • 338. For further info ● See “Git (software)” in Wikipedia ● And the git homepage http://git.or.cz ● Git wiki at http://git.or.cz/gitwiki ● Get on the mailing list
  • 339. For further info ● See “Git (software)” in Wikipedia ● And the git homepage http://git.or.cz ● Git wiki at http://git.or.cz/gitwiki ● Get on the mailing list − Helpful people there
  • 340. For further info ● See “Git (software)” in Wikipedia ● And the git homepage http://git.or.cz ● Git wiki at http://git.or.cz/gitwiki ● Get on the mailing list − Helpful people there − You can submit bugs, patches, ideas
  • 341. For further info ● See “Git (software)” in Wikipedia ● And the git homepage http://git.or.cz ● Git wiki at http://git.or.cz/gitwiki ● Get on the mailing list − Helpful people there − You can submit bugs, patches, ideas − Find out who else is using git

Hinweis der Redaktion