Git internals - commit

  • use git objects internal - prepare exercises
    • pack
    • git hooks
  • ref log - prepare exercises
  • more examples on the git log search
  • better prepare git bisect based on this one https://www.metaltoad.com/blog/beginners-guide-git-bisect-process-elimination
  • slides para a parte teorica
  • preparar melhor a parte do bisect com um repo ja pronto

This is internal stuff to git

Git From the Bits up - git internals - advanced

  • git is an API to build your collaborative workflows
  • git init creates a new repo
  • .git has a lot of things inside it
  • create a file in the root
    • git add the file to stage it
    • git commit stores the changes to git
  • .git has interesting stuff
    • refs is a sub-directory
    • it has heads and tags
    • git branch is a file
  • new git repo
    • mkdir .git
    • collection of objects and a system for naming the objects
      • system for naming are named “refs”
      • .git/refs
      • .git/objects
        • this folder stores all the versions of the files
      • .git/refs/heads
      • heads are known as branches
  • git commit anatomy
    • has object
      • computes a SHA1 hash and write that to the database
      • git help hash-object
      • git hash-object –stdin -w
      • pack will optimize the files size
      • git cat-file - prints the data from the file
      • git cat-file -p AND_ITS_HASH to show file log
        • git log –format=raw
    • GIT UPDATE-INDEX –ADD –cacheinfo
    • git model
      • file content is stored in a blob
      • a tree objects stores the file name and file mode and represents a directory
      • commit
    • git commit-tree -m
      • hashes
        • commit hashes
        • blob hashes
        • tree hashes
      • git commit owns a tree
      • and the tree owns other trees and blobs
    • refs
    • head
      • is the last commit created
      • refs point to a commit
      • detached head state is not good
        • you should not make changes
        • if you are detached and commit
    • git checkout
      • changes from a branch
      • git switch is also an option
  • Rebase is confused with merging - but they are different
    • direct rebase
      • branch off from another place that is not the HEAD
      • git branch feature my-hash
      • rebase does not creates a merge commit
        • git merge commit is: ADD HERE
      • rebase keeps the history clean ^8056cd
      • git reset –hard HASH
        • removes the commit
        • reflog - list of states that made changes in a commit
      • rebase allows fast-forward merge
    • interactive rebase
      • git rebase -i HEAD~10 - ~10 says how far I want to go in the history
      • is not possible to squash the top one
      • reflog stores everything there is we mass-up
      • rebase makes a lot of noise
    • rebase is safe when we do not push things to upstream

The definitive deep dive into the .git folder - Rob Richardson

Becoming a Git Mater - not that advanced

  • pro command prompt
    • shell configs
      • liquid prompt
      • git log –oneline
      • git commit -a –amend -C HEAD
        • add everything to the working tree and amend with the last commit
    • ignore file already commited
      • git update-index –assume-unchanged my-file - this hides files from git
      • git update-index –no-assume-unchanged my-file - shows back up the file to git
    • conflict resolutions
      • –ours - current code
      • – theirs - changes coming from outside
      • git checkout –ours my-branch
    • polish the commits
      • [[#^8056cd]] rebase
    • git submodules

Miscelanious

  • 80% is end user interface commands
  • git push –force
  • git cherry-pick
  • git ls-files
  • verified commits - GPG keys

References

  • https://initialcommit.com/blog
  • https://git.github.io/rev_news
  • https://blinry.itch.io/oh-my-git
    • reflog
    • https://stackoverflow.com/questions/61558808/git-log-reflog-vs-git-reflog
    • https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog
  • https://www.freecodecamp.org/news/how-git-bisect-makes-debugging-easier
  • https://kapeli.com/cheat_sheets/Oh-My-Zsh_Git.docset/Contents/Resources/Documents/index