Introduction to the

Read ing Git Version Control management (2nd edition) and make notes including shortcut keys, chapters, etc


notes

The third chapter

Instruction: config configuration

Git config -l --global git config --blobal git config --blobal git config --blobal git config --blobal git config --blobal git config --blobal git config --blobal git config --blobal git config --blobal git config Git config --unset --global git config alias Alias directive --global // Sets the alias globallyCopy the code

Chapter 4 Object library illustration

4.1.2 Git Data type

There are only four types of data in the Git repository:

  1. Bolbs: Large binary objects that store metadata without any other information
  2. Tree: represents a layer of directory information. It records bolB identifiers, path names, and all metadata of files under the directory. It can also recursively reference other trees
  3. Commit: Stores metadata of each commit change, including author confidence information, and each commit points to a tree
  4. Tag: Tag the submission

4.3.2 Objects, Hashes, bolB

When git creates an object, git does not care about the file name. Instead, it performs a sha1 hash on the metadata and puts the hashed value into the object library as the file name. Git/Objects is separated with the first byte as the directory name

Git cat-file -p hash on a bolB in the Objects directory to see the original contents of the block. Git ls-files-s git ls-files-s git ls-files-s git ls-files-s

Chapter v Document management and index

5.9 Detailed view of object models and files in Git

Schematic diagram:

Git changes diagram when modifying local files and committing

  1. Original Git status:

    Local two files, committed, index (staging) tree points to the same as the commit tree

  2. Local edit file1:

    Git status displays an unstagedfile, while the index and commit trees are clean

  3. Git add file1:

    Git status says add File. Git will create a new bold based on the modified file1 and point the index tree from File1 bolb to the new bolb. File2 still points to File2 bolb because it hasn’t changed.

  4. Git commit

    The index content is submitted to the branch, the index is consistent with the object library content, the repository is clean.

    When performing a commit, Git first creates a new commit tree (double triangle) based on the staging tree, then creates a commit object (double circle) pointing to the tree. The new commit object points to the old commit object, and the master points to the new commit object. At this point, the latest commit object’s tree points to the same content as the index tree

Chapter VI Submission

6.2.3 Relative submission names

Schematic diagram:



HEAD refers to the latest commit for the current branch

  1. ^ Refers to parent commit of different branches (different branches), ~ refers to parent commit of parent commit (same branch)
  2. ^1 == ~1 because both refer to the first parent of the current commit
  3. ^ 2! = ~2 because ^2 refers to the parent commit on the second branch, and ~2 refers to the parent commit of the parent commit
  4. ^^ == ~~ == 2 because ^^ refers to the parent commit (~) on the first branch (~~)
  5. Note ^ 2! = ^^ Please refer to the diagram above for details

6.3 Viewing Submission Records

  1. If the git log is followed by a commit name, the history will be displayed from that commit
  2. git log HEAD .. HEAD~2 prints commits from the current commit to the first two branches. Interval printing can be done using since.. Until prints a commit record
  3. Common –pretty=short displays brief information
  4. Common –abbrev-commit Displays abbreviated hash IDS
  5. Usually, -p displays the submitted changes
  6. Usually -n (n is a number) displays the number of lines printed
  7. The common –graph displays a line graph of submitted records

6.3.2 submit figure

Sublime Merge is highly recommended for viewing submit charts, which is intuitive and easy, but too painful to type on the command line

6.4 Lookup submission

Git bisect positioning error, the concrete used, to study the git blame is positioning error, nor used…

Chapter 8 of the diff

8.1 Git diff Format

  • Git diff: Displays the difference between the working directory and the index, used when the local directory is dirty
  • GIF diff commit: Displays the difference between the working directory and the commit. Usually HEAD or a branch is used as a commit
  • Git diff –cached commit: Displays the difference between the change in the index and the given commit
  • Git diff commit1 COMMIT2: Displays the difference between any two commits, ignoring the index and the working directory and comparing the two trees in the object library
  • Git diff commit1 commit git diff commit1 commit git diff commit1 commit git diff commit1 commit
  • git diff commit1 .. Commit2: Same as above, compare the difference between two commits

Parameter: –stat: displays statistical differences without displaying specific content differences. –color: displays multi-color output -w or –ignore-all-space: ignores whitespace characters when comparing. -s “Search string” : displays the differences between submissions containing strings

Chapter ix of the merge

9.1.3 Conflicting merges

Git commit (with no parameters), merge the file, save the file, merge the file

Chapter 10 Submission of Changes

10.2 Using Git Reset

The HEAD pointer can be used to point to any submission with three arguments:

  • Git status will find that the working directory of the soft index has the same contents as the HEAD index.
  • — Mixed index changes with HEAD to point to a new commit, git status will find that the index has no content, and the working directory has content.
  • — Hard HEAD, index, working directory change together, git status see nothing

10.6 Modifying the latest Submission

Git commit — Amend will open the editor, modify the last submission information, the content in the index this time to the last submission of the content can be followed by the parameter –author [author name < email >], directly modify the author of this submission, email

10.7 Base change submission

Forward porting:

Git rebase: change the dependencies of the current branch to the HEAD of the target branch

Example: Git Rebase Master Topic

Git rebase: git rebase –onto

Git rebase –onto master maint~ feature

Note that the rebase operation migrates the commit one at a time. Each migration may have conflicts, which need to be handled:

  1. Git rebase –continue after handling the conflict
  2. Use git rebase –skip the current commit and move on to the next one, but this can lead to snowballing errors
  3. Use git rebase –abort to abort the base change, and the repository returns to its original state

Git rebase -i: git rebase -i will open a text editor that lets you change how to handle base changes between interactive abort commits

10.7.2 Rebasing and Merging

  • git pull = git fetch + git merge
  • git pull –rebase = git fetch + git rebase

Merge merges two branches into one commit, and the commit graph is two lines, whereas rebase bases the current branch on the latest node of the target branch, and the commit graph is a straight line

Chapter 11 Storing and referencing logs

11.1 storage

  • Git Stash Save [text message] : Temporary workspace, which is pushed sequentially
  • Git Stash: Equivalent to git Stash save, this saves the current workspace directly and does not add text messages
  • Git stash pop [stash name /index] :
    1. Stash name: stash@{0}
    2. Stash index: 0,1,2, which can be obtained with git stash list
  • Git Stash List: View all the staging
  • Git stash show [stash name /index] : to view the contents of a temporary stash, the -p parameter is used to view the contents of the file
  • Git stash drop [stash name /index] : Drops a stash

Update ing