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