GIT - THERE BE DRAGONS! from (L)User to R00t in 60 Minutes

GIT - THERE BE DRAGONS! from (L)User to R00t in 60 Minutes

GIT - THERE BE DRAGONS! from (l)user to r00t in 60 minutes Javier L. Gómez January 28, 2019 Computer Architecture and Technology Area (ARCOS)—University Carlos III of Madrid LICENSE This presentation can be redistributed and/or modified under the terms of CC-BY-NC license. 1/52 Agenda 1 Introduction 2 Git essentials 3 [(l)user] Porcelain 4 [sudoer] More porcelain 5 [r00t] Plumbing 6 Additional stuff 7 Conclusion 2/52 Introduction SCM/Revision control systems “Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later (…) if you screw things up or lose files, you can easily recover.” [https:///git-scm.org/] What you get: Compare changes over time or revert files. See who introduced an issue. Make experimental changes (and merge them). … 3/52 RCS models: centralized/distributed Centralized: Subversion (SVN), Distributed: git, Mercurial (hg)… CVS… 4/52 git - the stupid content tracker (1/3) This is not GitHub, nor GitLab… 5/52 git - the stupid content tracker (2/3) Git: a distributed RCS. Started by Linus Torvalds; currently maintained by Junio C Hamano. 6/52 git - the stupid content tracker (3/3) 139 separate binaries, wrapped by git(1); some of them accept lots of options! e.g. git-log parses 100+ options Divided into high level (porcelain) and low level (plumbing) commands Largely documented: $ basename --suffix=.1.gz /usr/share/man/man1/git* | xargs man | wc -l 53260 (=870 pages PDF) Target of this talk: people using Git 7/52 Minimum set of commands Initialization git clone git init Interrogation git log git status git diff Manipulation git add git commit Interaction git push git pull 8/52 Git essentials Working tree and .git/ directory (1/2) repository/ .git/ directory: contains Git .git/ config administrative and control files. HEAD … Working tree: the tree of checked Makefile main.cpp out files. … 9/52 Working tree and .git/ directory (2/2) Bare repository: NO working tree + NO .git/ directory repository.git/ config sub-directory. HEAD … Git files directly present in the directory. 10/52 Ref(erence): a name that points to an object. Hierarchical namespace rooted at refs/ Symref: a ref that points to another ref, e.g. HEAD. Objects, references and symrefs (1/3) Object: raw octets stored in Git; identified by its SHA-1. Types: commit, tree, blob, tag. 11/52 Symref: a ref that points to another ref, e.g. HEAD. Objects, references and symrefs (1/3) Object: raw octets stored in Git; identified by its SHA-1. Types: commit, tree, blob, tag. Ref(erence): a name that points to an object. Hierarchical namespace rooted at refs/ 11/52 Objects, references and symrefs (1/3) Object: raw octets stored in Git; identified by its SHA-1. Types: commit, tree, blob, tag. Ref(erence): a name that points to an object. Hierarchical namespace rooted at refs/ Symref: a ref that points to another ref, e.g. HEAD. HEAD refs/heads/master 770fcfa540f5f5d1f49570b9d09320c7a7b7e879 (commit) 11/52 Tree: directory contents. Commit: information about a revision. Tag: ref pointing to a commit + message + PGP signature (optional). Objects, references and symrefs (2/3) The contents of an object depend on its type: Blob: raw data; stores file contents. 9355a87 # # /etc/hosts: … 0632e41 # Generated by NetworkManager search arcos.… 12/52 Commit: information about a revision. Tag: ref pointing to a commit + message + PGP signature (optional). Objects, references and symrefs (2/3) The contents of an object depend on its type: Blob: raw data; stores file contents. 9355a87 # # /etc/hosts: … Tree: directory contents. 3814f01 hosts 0632e41 resolv.conf # Generated by NetworkManager search arcos.… 12/52 Tag: ref pointing to a commit + message + PGP signature (optional). Objects, references and symrefs (2/3) The contents of an object depend on its type: Blob: raw data; stores file 9355a87 # contents. # /etc/hosts: … 3814f01 hosts efa21b0 0632e41 Tree: directory contents. resolv.conf # Generated by NetworkManager Commit: information about a search arcos.… revision. 12/52 Objects, references and symrefs (2/3) The contents of an object depend on its type: Blob: raw data; stores file 9355a87 # contents. # /etc/hosts: … 3814f01 hosts efa21b0 0632e41 Tree: directory contents. resolv.conf # Generated by a27c52b NetworkManager Commit: information about a search arcos.… revision. Tag: ref pointing to a commit + message + PGP signature (optional). 12/52 Objects, references and symrefs (3/3) Typically, objects can be reached given a ref (but not always). refs/heads/master refs/heads/master Unreachable object: an object Dangling object: not reachable which is not reachable from even from other unrechable any reference. objects. More at gitglossary(7)13/52 Project history, branches and tags refs/heads/master Commit objects form a DAG (they point to refs/heads/foo their parents). This DAG is known as the history of a project. refs/remotes/o-rigin/master 14/52 Project history, branches and tags Commit objects form a DAG (they point to refs/heads/master their parents). This DAG is known as the refs/heads/foo history of a project. Branch: an active line of development; tip: the most recent commit. refs/remotes/o-rigin/master 14/52 Project history, branches and tags Commit objects form a DAG (they point to their parents). This DAG is known as the history of a project. refs/heads/master refs/heads/foo Branch: an active line of development; tip: the most recent commit. (Branch) head: a reference to the tip of a branch. refs/remotes/o-rigin/master Local heads at: refs/heads/. 14/52 Project history, branches and tags Commit objects form a DAG (they point to their parents). This DAG is known as the history of a project. Branch: an active line of development; refs/heads/master tip: the most recent commit. refs/heads/foo (Branch) head: a reference to the tip of a branch. Local heads at: refs/heads/. Remote-tracking branch: a ref to a refs/remotes/o-rigin/master remote head; follow changes from another repository. At refs/remotes/*/. 14/52 Project history, branches and tags Commit objects form a DAG (they point to their parents). This DAG is known as the refs/heads/master refs/heads/foo history of a project. Merge commit: a commit object that has ≥ 2 parents. Octopus: a merge that has > 2 parents. refs/remotes/o-rigin/master 14/52 For each file, it stores <object SHA-1> <attributes1> 100644 01cb7066623241a0e5714a6630f0355eb0c80de4 0 .gitignore … 100644 94fbec4cf383e9122c22d60cfad91b3c897e2c63 0 slides.tex Changes to the working tree found by comparing these attributes. Entries may be updated (git add) and new commits may be created from the index. The “index” (cache) file Short story: basically, it is the staging area for the next commit. “A collection of files with stat information, whose contents are stored as objects.” [gitglossary(7)] 1Last modified time, size, etc. 15/52 Changes to the working tree found by comparing these attributes. Entries may be updated (git add) and new commits may be created from the index. The “index” (cache) file Short story: basically, it is the staging area for the next commit. “A collection of files with stat information, whose contents are stored as objects.” [gitglossary(7)] For each file, it stores <object SHA-1> <attributes1> 100644 01cb7066623241a0e5714a6630f0355eb0c80de4 0 .gitignore … 100644 94fbec4cf383e9122c22d60cfad91b3c897e2c63 0 slides.tex 1Last modified time, size, etc. 15/52 Entries may be updated (git add) and new commits may be created from the index. The “index” (cache) file Short story: basically, it is the staging area for the next commit. “A collection of files with stat information, whose contents are stored as objects.” [gitglossary(7)] For each file, it stores <object SHA-1> <attributes1> 100644 01cb7066623241a0e5714a6630f0355eb0c80de4 0 .gitignore … 100644 94fbec4cf383e9122c22d60cfad91b3c897e2c63 0 slides.tex Changes to the working tree found by comparing these attributes. 1Last modified time, size, etc. 15/52 The “index” (cache) file Short story: basically, it is the staging area for the next commit. “A collection of files with stat information, whose contents are stored as objects.” [gitglossary(7)] For each file, it stores <object SHA-1> <attributes1> 100644 01cb7066623241a0e5714a6630f0355eb0c80de4 0 .gitignore … 100644 94fbec4cf383e9122c22d60cfad91b3c897e2c63 0 slides.tex Changes to the working tree found by comparing these attributes. Entries may be updated (git add) and new commits may be created from the index. 1Last modified time, size, etc. 15/52 Other definitions (1/3) Fast-forward: a special type of merge; given two heads A and B, merging B into A is considered fast-forward if merge_base(A; B) == A, i.e. A is ancestor of B. B B A A Fast-forward (update ref only!) Non fast-forward (requires a merge) 16/52 Detached HEAD: HEAD may also point at an arbitrary commit, i.e. “detached” from any branch. You may make commits in this state, but… Other definitions (2/3) HEAD: symref that HEAD dereferences to the current checked-out head. refs/heads/master c864ac8 17/52 Other definitions (2/3) HEAD: symref that dereferences to the current checked-out head. refs/heads/master Detached HEAD: HEAD may HEAD also point at an arbitrary commit, i.e. “detached” from any branch. You may make c864ac8 commits in this state, but… 17/52 Other definitions (2/3) HEAD: symref that dereferences to the current checked-out head. HEAD refs/heads/master Detached HEAD: HEAD may also point at an arbitrary commit, i.e. “detached” from any branch. You may make c864ac8 commits in this state, but… 17/52 Other definitions (2/3) HEAD: symref that HEAD dereferences to the current checked-out head. refs/heads/master Detached HEAD: HEAD may also point at an arbitrary commit, i.e. “detached” from any branch.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    118 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us