git authoritative guide (note)

Source: Internet
Author: User
Tags sha1 svn update

git authoritative guideJump to: Navigation, search
Directory
  • 1 initial knowledge of Git
  • 2 git installation
  • 3 git initialization
  • 4 git staging Area (stage)
  • 5 git objects
  • 6 git reset
  • 7 git check out
  • 8 git stash
  • 9 git basic Operations
  • Ten History
  • One git cloning
  • A git Library Management
  • - git protocol and work collaboration
  • - Conflict Resolution
  • the git milestones
  • - git branch
  • - Remote Version Library
  • - Patch file Interaction
  • + Classic git collaboration model
  • - Topgit Synergy Model
  • + Sub-module (submodule) collaboration Model
  • A Sub-tree merging *
  • at Android Multi-version library collaboration
  • - git and SVN collaboration model
  • - git server
    • 25.1 Gitolite
    • 25.2 gitosis
    • 25.3 Gerrit Code Review
    • 25.4 git hosting
  • - migrating to Git
  • - other apps for Git
  • - other features of Git
  • in Appendix
initial knowledge of Git
    1. git add-u/-a/-p
    2. git pull remote-mirror local-master
    3. Export Commit history (that is, generate patches from an existing code):
      1. Initialize G It repository ... (This step can actually be time consuming, if the code is large)
      2. git tag v1
      3. git commit-a
      4. git format-patch v1. HEAD This requires each commit to be a fix, and in practice may want to merge all submissions into one patch ...
    4. Rewrite commit description: Git commit--amend (patch commit, modify last commit???
      1. To modify the description of the history submission, you need to first locate: Git rebase-i <commit-id> (suspect this is not rebase here?).
    5. git diff
      1. --word-diff
      2. --cached
    6. Save and restore work progress (push/pop ):
      1. git stash (relative to push)
      2. git checkout <new_branch>
      3. ...
      4. git checkout <origin_branch>
      5. git stash pop
    7. local git, with server-side svn:
      1. git svn fetch (which is equivalent to executing SVN update in a git-controlled environment?).
      2. git svn rebase
      3. git svn dcommit
    8. git command default paging (LESS-FRSX)
git installation
    1. Get the latest version and discard local modifications:
      1. git fetch
      2. Git clean-fdx
      3. git reset--hard
      4. git tag
      5. git checkout v1.7.4.1
    2. Command? /etc/bash_completion
    3. Chinese support: git config--global core.quotepath false
      1. On Linux, it is best not to use a character set other than UTF-8 (GBK)
    4. Install git:$ Brew install git on Mac OS x
    5. P40 Cygwin uses the UTF-8 character set by default and intelligently transforms it with the Windows character set (?). )
    6. PuTTY Pageant: Provide SSH private key?
    7. Msysgit Environment:
      1. $ ls--show-control-chars *.txt (show Chinese file name)
      2. Tortoisegit the support of Chinese submission description is defective??? Nonsense
git initialization
    1. git grep
    2. Git rev-parse--git-dir
    3. git config makes it easy to manipulate INI files:
      1. Git_config=test.ini git CONFIG a.b.c "Hello"
    4. Alias: git config--global alias.ci "commmit-s"
git staging Area (stage)
    1. When executing git status (-s) displays the stage content? ), first determine if the workspace has changed based on information such as the timestamp of the. Git/index
      1. (The design that relies on file timestamps is inherently not too reliable ... )
    2. Git-diff comparison:
      1. Workspaces vs Staging Area: Git diff
      2. Staging Area vs Head:git diff--cached
      3. Workspace vs Head:git diff HEAD
    3. Do not use Git commit-a (bypass stage, submit directly)
    4. Each modification requires git add to add to the stage (this add really makes it easy to confuse people!). )
git objects
    1. Git cat-file [-t-p ...] <SHA1-40bit-ID>
    2. . Git/objects:id the first 2 bits as the directory name, the last 38 bits as the file name??
    3. The reference name under. git/refs/heads/is called a branch (the reference points to a commit id! # P90 HG uses both sequential numbers and SHA1??
    4. head^ represents the last commit of head
    5. A5~5 equivalent to a5^ ^^ ^^
    6. A5:path/to/file
git reset
    1. git reset--hard head^ (changes in the staging area may be lost)
    2. git reset--hard 9e8a761
    3. git reflog Show Master | Head-5
    4. git reset--hard [email protected]{2} switch master back to 2 changes
    5. 2 Types of Reset
      1. git reset [-Q] [<commit>] [--] <paths> ...
      2. Git reset[--soft/--mixed/--hard/--merge/--keep] [-Q] [<commit>]
git check out
    1. Reset current head when checkout
    2. P102 when the commit is not checked out and submitted from master, it may be purged from the repository because the submission is not tracked by the branch
    3. Rescue: Switch to master, then merge the commit just now (Development Branch?). ):
      1. git merge acc2f9
    4. git log--graph--pretty=online
    5. The default for *reset is head, while the default for checkout is Stage (index)
    6. Check out and create a new branch: Git Checkout [-M] [[-B/--orphan] <new_branch>] [<start_point>]
git stash
    1. Git stash (save current work progress, respectively to stage, working) can save progress many times! (Save point?) )
    2. Git-<cmd>:git Most of the commands are also script-implemented (! ), which is similar to the HG
    3. Stash internal implementation is actually a special Branch (Refs/stash).
      1. Compared to the SVN trunk/tags/branch directory, Git has built this state into the command (which I think it's easier for SVN to say)
      2. Concatenation of 2 SVN is actually the same as the git stage, haha
git basic Operations
    1. Git stash apply (pop will delete the progress?) )
    2. Local deletion does not affect the stage, while Git RM modifies the stage and the next commit takes effect
    3. git add parameter
      1. -U: Mark all local changes (update, delete)
      2. -A: All changes and additions
      3. -I: Interactive manual selection
    4. git describe
    5. . gitignore
      1. /todo only ignores TODO in this directory
      2. . svn/all. SVN (child) directories
    6. Git Archive--format=tar--prefix=1.0/v1.0 | gzip > foo-v1.0.tag.gz
History
    1. GITK--all
    2. GITK--since= "2 weeks Ago" #这种时间描述应该是从Ruby里借鉴来的
    3. GITG & (GTK + based)
    4. Qgit & (QT-based)
    5. git blame-l 6,+5 Readme.txt
    6. git bisect start/good/bad/reset
    7. * Hg can only regret once, git because there is a strong reset, can be any number of times
    8. Time travel "Back to the Future" (this metaphor is really inappropriate!) )
      1. Git Cherry-pick
      2. git rebase--onto <newbase> <since> <until>
      3. Git rebase-i
    9. Discard history and keep only the last 100 commits:
      1. Create root commit: Git cat-file commit a^0 | Sed-e '/^parent/d ' > Tmpfile
      2. git hash-object-t commit-w--tmpfile
      3. git rebase--onto <new-root-commit-id> A Master
    10. The method of correcting an error commit in a distributed situation is to reverse the commit:
      1. git revert HEAD
git cloning
    1. git clone <repos> <new-dir>
      1. Without parameters (non-bare repository, Workspace Direct push causes an error?). Allow pull only from backup library, cannot reverse push? )
      2. --bare (only. git/, bare version library, can push)
      3. --mirror
        1. can be synchronized with upstream git fetch
    2. Git push/pull [<remote-repos> [<ref-specs>]
git Library Management
    1. Git show-ref
      1. Refs/heads/begins with a branch
      2. Refs/remotes/is a local mapping branch of a remote branch
      3. Refs/tags/is a milestone
    2. * Why does the clone remote repository produce object library packaging and reference packaging effects? (The file was compressed when it was transmitted ...) )
    3. Git fsck
      1. Loose objects with no referenced associations, such as large files introduced by staging area
      2. Git prune
    4. Git fsck--no-reflogs
      1. git reflog expire--expire=now--all
      2. Git prune
    5. Git GC
      1. --prune=now
    6. 1.6.6+ partial git command automatically executes git GC--auto
      1. git merge
      2. Git Receive-pack (when receiving push from the other party)
      3. Git rebase-i
      4. git am
    7. Trigger condition: When more than 27 objects are in the. GIT/OBJECTS/17 Directory
git protocol and work collaboration
    1. Smart Protocol vs Dumb Protocol (. git/info/refs,git/objects/info/packs)
    2. ' Fast-forward ' push: Push pushes must be based on the existing base of the corresponding branch of the repository
    3. Force push (which in this case overwrites the other user's,??). )
    4. Merge post push:
      1. Git pull
      2. git push
    5. Prohibit ' fast-forward ' push:
      1. Git--git-dir=/path/to/repos/shared.git config receive.denynonfastforwards true
    6. Allow specific users to force push (...) through hooks and authorization. )
Conflict Resolution
    1. Git pull = fetch + Merge
    2. Auto Merge
      1. Different files
      2. Non-peers of the same file
      3. File Movement & Modification of file contents
    3. Automatic merge succeeded, but there was a logical conflict: Test!!!
    4. Conflict Resolution:<<<<<<<=======>>>>>>>
      1. Kdiff3
    5. Tree clash
    6. Merge strategy: git merge [-s <strategy>] [-X <strategy-options>] <commit> ...
      1. Ours
      2. Theirs
      3. Subtree
      4. Octopus
git milestones
    1. git tag
    2. Naming specification: V1.0-init
      1. Don't start with--
      2. /. Cannot appear in the last
      3. Cannot appear more than 2 consecutive.
      4. Cannot use special characters: ~ ^:? \
      5. Cannot end with. Lock
git branch
    1. Master: Changes as you submit
    2. Publishing Branch (Bugfix)
    3. Feature Branch
    4. Vendor branch (specifically creating a branch with upstream synchronization)
    5. Git branch dever-name/feature-name (branch name band/? )
    6. Merge to Main Line:
      1. git checkout Master
      2. git merge User1/funca
      3. Git cherry
      4. git push
      5. Git branch-d User1/funca
    7. The branching diagram with Rebase is simpler than merge?
Remote Version Library
    1. Git branch-r
      1. . git/refs/remotes/origin/#see. Git/config
    2. To create a trace branch from a remote branch: git checkout-b v-1.x origin/v-1.x (direct git checkout v-1.x If there is no name conflict)
      1. The advantage of tracking branches is that git pull automatically maintains consistent updates to the upstream branch
      2. If you want to support tracing for your local branch:--track
    3. Registering a new remote repository: Git remote add new-remote-name <URL-to-remote-repos-git>
    4. git Remote update
    5. tags in the remote repository sync to local, no new namespaces are created!!
      1. -N (--no-tags)
Patch file Interaction
    1. To create a patch:
      1. Git format-patch-s head~3..head (last 3 commits exported as patch files)
    2. Accept Mail: mail-f user1-archive (mbox format)
    3. First switch to the local datum point: Git checkout-b user1-patch-base head~3
    4. Apply Patch: Git am user1-archive
      1. Or you can: Cat *.patch | git am
    5. git apply: Apply general-format patches, but do not submit
    6. Stgit (I don't see how it's useful in the end)
      1. STG Uncommit-n 3
      2. STG Pop-a (undo the Commit on the repository?) )
      3. STG ser
      4. STG Push/goto ...
      5. STG Refresh
      6. STG Show
      7. STG export (quilt format? )
    7. Quilt
Classic git collaboration model
    1. Hg + MQ
      1. into the stack to commit the patch, the stack is to remove the latest submission
Topgit Synergy Model
    1. Master for synchronizing with upstream, establishing local feature branches (REFS/HEADS/T/FEATURE_NAME)
    2. To implement feature branching as patches, a special reference (refs/top-bases/*) is introduced to track the base branch of each feature branch
    3. TG Create T/new-feature-branch-name [DEPS ...] can specify multiple dependent branches???
      1. When the dependent branch is updated, the TG info t/feature3 can see the commit on the T/feature1
    4. TG Update
    5. TG Summary
      1. --graphviz | Dot-t Png-o Topgit-layout.png
    6. TG remote [--populate] [remote]
    7. TG Export
      1. --collapse
    8. . Topdeps: Remove duplicate dependencies??
Sub-module (submodule) collaboration Model
    1. Svn:externals
    2. git submodule add/path/to/repos/liba.git lib/lib_a
    3. Clone does not contain submodules by default, if necessary,
      1. Git submodule init
      2. git submodule update
    4. ??? The explanation here is too vague ... Fuck
Sub-tree merging *
    1. git read-tree--prefix=lib util-branch
    2. Git checkout-lib
    3. Git write-tree
    4. Git commit-tree ...
    5. Reverse direction: Export a subdirectory of the project to a new GIT project that requires export of the corresponding history ...
      1. #see git filter-branch
    6. Git-subtree Plugin *
Android Multi-version library collaboration
    1. Repo (equivalent to using a Python script to organize multiple git repositories with directories ...) , manifest.xml)
    2. Repo Init--mirror-u Git://.../manifest.git
      1. Repo Sync
    3. Repo upload: Git push to the Gerrit server
git and SVN collaboration model
    1. Git svn clone <svn-path> <dir-name>
    2. Git svn fetch
    3. Git svn rebase (note that SVN commits are linear!) )
    4. Git rebase--continue
    5. Git svn dcommit
      1. After the push, Git's commit description is embedded in the Git-svn-id: tag (add the mapping relationship to git commit log, smart!). )
    6. Note: Try not to merge between different branches when using GIT-SVN, but rather to submit them linearly on one branch as much as possible
      1. If you really need to merge between the branches in SVN, use SVN 1.5+, as this will correctly record the Svn:mergeinfo property
git server
    1. Read-Only HTTP dummy protocol
    2. Smart http:1.6.6+ Git-http-backend
    3. Gitweb: Read-only access?
      1. Git instaweb (if installed)
    4. Git-daemon
    5. SSH mode
Gitolite
    1. It's Perl again?
    2. Gitolite-admin Management library? (Devops?) )
    3. Access control and authorization: slightly
gitosis
    1. Python development, SKIP
Gerrit Code Review
    1. The earliest Gerrit from the Rietveld branch developed by the father of Python, Guido van Rossum, now Gerrit is implemented in Java
    2. Special references:
      1. Refs/for
        1. Create a <review-id>, and build refs/changes/nn/<review-id>/m
      2. Refs/changes
    3. Hooks/commit-msg
      1. Change-id
    4. Gerrit Server Setup: ... Slightly
      1. The first user is a system administrator, and a public key is established to start the SSH service
git hostingmigrating to Git
    1. CVS2SVN > Cvs2git
    2. HG migration to Git:fast-export (slightly)
other apps for Git
    1. Etckeeper
    2. Gistore,shit developed by the author himself
    3. git diff--binary
other features of Git
    1. Properties file?
    2. Hooks
      1. Applypatch-msg
      2. Pre/post-applypatch
      3. Pre/post-commit
      4. Prepare-commit-msg
      5. Commit-msg
      6. Pre-rebase
      7. Post-checkout/merge
      8. Pre/post-receive
      9. Update
      10. Post-update
      11. Pre-auto-gc
      12. Post-rewrite
    3. Sparse Checkout
      1. Skip-worktree
    4. Shallow clone:
      1. --depth 2
        1. . Git/shadow
    5. Submit graft:. git/info/grafts
    6. Commit replacement:. git/refs/replace/
    7. Git notes
Appendix

git authoritative guide (note)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.