1、克隆远程代码库 git clone
- qiaozhiguang@XSLUser[master*]$git clone -help
- usage: git clone [<options>] [--] <repo> [<dir>]
- -v, --verbose be more verbose
- -q, --quiet be more quiet
- --progress force progress reporting
- -n, --no-checkout don't create a checkout
- --bare create a bare repository
- --mirror create a mirror repository (implies bare)
- -l, --local to clone from a local repository
- --no-hardlinks don't use local hardlinks, always copy
- -s, --shared setup as shared repository
- --recursive initialize submodules in the clone
- --recurse-submodules initialize submodules in the clone
- --template <template-directory>
- directory from which templates will be used
- --reference <repo> reference repository
- --dissociate use --reference only while cloning
- -o, --origin <name> use <name> instead of 'origin' to track upstream
- -b, --branch <branch>
- checkout <branch> instead of the remote's HEAD
- -u, --upload-pack <path>
- path to git-upload-pack on the remote
- --depth <depth> create a shallow clone of that depth
- --single-branch clone only one branch, HEAD or --branch
- --separate-git-dir <gitdir>
- separate git dir from working tree
- -c, --config <key=value>
- set config inside the new repository
2、创建本地代码仓库 git init
- qiaozhiguang@XSLUser[master*]$git init -help
- usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]
- --template <template-directory>
- directory from which templates will be used
- --bare create a bare repository
- --shared[=<permissions>]
- specify that the git repository is to be shared amongst several users
- -q, --quiet be quiet
- --separate-git-dir <gitdir>
- separate git dir from working tree
3、添加命令 git add
- qiaozhiguang@XSLUser[master*]$git add -help
- usage: git add [<options>] [--] <pathspec>...
- -n, --dry-run dry run
- -v, --verbose be verbose
- -i, --interactive interactive picking
- -p, --patch select hunks interactively
- -e, --edit edit current diff and apply
- -f, --force allow adding otherwise ignored files
- -u, --update update tracked files
- -N, --intent-to-add record only the fact that the path will be added later
- -A, --all add changes from all tracked and untracked files
- --ignore-removal ignore paths removed in the working tree (same as --no-all)
- --refresh don't add, only refresh the index
- --ignore-errors just skip files which cannot be added because of errors
- --ignore-missing check if - even missing - files are ignored in dry run
4, git tag 标签命令
- qiaozhiguang@XSLUser[master*]$git tag -help
- usage: git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <tagname> [<head>]
- or: git tag -d <tagname>...
- or: git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]
- [<pattern>...]
- or: git tag -v <tagname>...
- -l, --list list tag names
- -n[<n>] print <n> lines of each tag message
- -d, --delete delete tags
- -v, --verify verify tags
- Tag creation options
- -a, --annotate annotated tag, needs a message
- -m, --message <message>
- tag message
- -F, --file <file> read message from file
- -s, --sign annotated and GPG-signed tag
- --cleanup <mode> how to strip spaces and #comments from message
- -u, --local-user <key-id>
- use another key to sign the tag
- -f, --force replace the tag if exists
- Tag listing options
- --column[=<style>] show tag list in columns
- --sort <type> sort tags
- --contains <commit> print only tags that contain the commit
- --points-at <object> print only tags of the object
5、git pull 拉取远程代码仓库,并与本地代码仓库 merge
- qiaozhiguang@XSLUser[master*]$git pull -help
- usage: git pull [options] [<repository> [<refspec>...]]
- Fetch one or more remote refs and integrate it/them with the current HEAD.
- -v, --verbose be more verbose
- -q, --quiet be more quiet
- --progress force progress reporting
- Options related to merging
- -r, --rebase[=<false|true|preserve>]
- incorporate changes by rebasing rather than merging
- -n do not show a diffstat at the end of the merge
- --stat show a diffstat at the end of the merge
- --summary (synonym to --stat)
- --log[=<n>] add (at most <n>) entries from shortlog to merge commit message
- --squash create a single commit instead of doing a merge
- --commit perform a commit if the merge succeeds (default)
- -e, --edit edit message before committing
- --ff allow fast-forward
- --ff-only abort if fast-forward is not possible
- --verify-signatures verify that the named commit has a valid GPG signature
- -s, --strategy <strategy>
- merge strategy to use
- -X, --strategy-option <option>
- option for selected merge strategy
- -S, --gpg-sign[=<key-id>]
- GPG sign commit
- Options related to fetching
- --all fetch from all remotes
- -a, --append append to .git/FETCH_HEAD instead of overwriting
- --upload-pack <path> path to upload pack on remote end
- -f, --force force overwrite of local branch
- -t, --tags fetch all tags and associated objects
- -p, --prune prune remote-tracking branches no longer on remote
- --recurse-submodules[=<on-demand>]
- control recursive fetching of submodules
- --dry-run dry run
- -k, --keep keep downloaded pack
- --depth <depth> deepen history of shallow clone
- --unshallow convert to a complete repository
- --update-shallow accept refs that update .git/shallow
- --refmap <refmap> specify fetch refmap
6、git push 将本地代码仓库 推送到远程代码仓库
- qiaozhiguang@XSLUser[master*]$git push -help
- usage: git push [<options>] [<repository> [<refspec>...]]
- -v, --verbose be more verbose
- -q, --quiet be more quiet
- --repo <repository> repository
- --all push all refs
- --mirror mirror all refs
- --delete delete refs
- --tags push tags (can't be used with --all or --mirror)
- -n, --dry-run dry run
- --porcelain machine-readable output
- -f, --force force updates
- --force-with-lease[=<refname>:<expect>]
- require old value of ref to be at this value
- --recurse-submodules[=<check|on-demand>]
- control recursive pushing of submodules
- --thin use thin pack
- --receive-pack <receive-pack>
- receive pack program
- --exec <receive-pack>
- receive pack program
- -u, --set-upstream set upstream for git pull/status
- --progress force progress reporting
- --prune prune locally removed refs
- --no-verify bypass pre-push hook
- --follow-tags push missing but relevant tags
- --signed GPG sign the push
- --atomic request atomic transaction on remote side
7、查看状态 git status
- qiaozhiguang@XSLUser[master*]$git status -help
- usage: git status [<options>] [--] <pathspec>...
- -v, --verbose be verbose
- -s, --short show status concisely
- -b, --branch show branch information
- --porcelain machine-readable output
- --long show status in long format (default)
- -z, --null terminate entries with NUL
- -u, --untracked-files[=<mode>]
- show untracked files, optional modes: all, normal, no. (Default: all)
- --ignored show ignored files
- --ignore-submodules[=<when>]
- ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
- --column[=<style>] list untracked files in columns
8、git commit
- qiaozhiguang@XSLUser[master*]$git commit -help
- usage: git commit [<options>] [--] <pathspec>...
- -q, --quiet suppress summary after successful commit
- -v, --verbose show diff in commit message template
- Commit message options
- -F, --file <file> read message from file
- --author <author> override author for commit
- --date <date> override date for commit
- -m, --message <message>
- commit message
- -c, --reedit-message <commit>
- reuse and edit message from specified commit
- -C, --reuse-message <commit>
- reuse message from specified commit
- --fixup <commit> use autosquash formatted message to fixup specified commit
- --squash <commit> use autosquash formatted message to squash specified commit
- --reset-author the commit is authored by me now (used with -C/-c/--amend)
- -s, --signoff add Signed-off-by:
- -t, --template <file>
- use specified template file
- -e, --edit force edit of commit
- --cleanup <default> how to strip spaces and #comments from message
- --status include status in commit message template
- -S, --gpg-sign[=<key-id>]
- GPG sign commit
- Commit contents options
- -a, --all commit all changed files
- -i, --include add specified files to index for commit
- --interactive interactively add files
- -p, --patch interactively add changes
- -o, --only commit only specified files
- -n, --no-verify bypass pre-commit hook
- --dry-run show what would be committed
- --short show status concisely
- --branch show branch information
- --porcelain machine-readable output
- --long show status in long format (default)
- -z, --null terminate entries with NUL
- --amend amend previous commit
- --no-post-rewrite bypass post-rewrite hook
- -u, --untracked-files[=<mode>]
- show untracked files, optional modes: all, normal, no. (Default: all)
9、git branch
- qiaozhiguang@XSLUser[master*]$git branch -help
- usage: git branch [<options>] [-r | -a] [--merged | --no-merged]
- or: git branch [<options>] [-l] [-f] <branch-name> [<start-point>]
- or: git branch [<options>] [-r] (-d | -D) <branch-name>...
- or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
- Generic options
- -v, --verbose show hash and subject, give twice for upstream branch
- -q, --quiet suppress informational messages
- -t, --track set up tracking mode (see git-pull(1))
- --set-upstream change upstream info
- -u, --set-upstream-to <upstream>
- change the upstream info
- --unset-upstream Unset the upstream info
- --color[=<when>] use colored output
- -r, --remotes act on remote-tracking branches
- --contains <commit> print only branches that contain the commit
- --abbrev[=<n>] use <n> digits to display SHA-1s
- Specific git-branch actions:
- -a, --all list both remote-tracking and local branches
- -d, --delete delete fully merged branch
- -D delete branch (even if not merged)
- -m, --move move/rename a branch and its reflog
- -M move/rename a branch, even if target exists
- --list list branch names
- -l, --create-reflog create the branch's reflog
- --edit-description edit the description for the branch
- -f, --force force creation, move/rename, deletion
- --no-merged <commit> print only not merged branches
- --merged <commit> print only merged branches
- --column[=<style>] list branches in columns
10,git checkout
- qiaozhiguang@XSLUser[master*]$git checkout -help
- usage: git checkout [<options>] <branch>
- or: git checkout [<options>] [<branch>] -- <file>...
- -q, --quiet suppress progress reporting
- -b <branch> create and checkout a new branch
- -B <branch> create/reset and checkout a branch
- -l create reflog for new branch
- --detach detach the HEAD at named commit
- -t, --track set upstream info for new branch
- --orphan <new-branch>
- new unparented branch
- -2, --ours checkout our version for unmerged files
- -3, --theirs checkout their version for unmerged files
- -f, --force force checkout (throw away local modifications)
- -m, --merge perform a 3-way merge with the new branch
- --overwrite-ignore update ignored files (default)
- --conflict <style> conflict style (merge or diff3)
- -p, --patch select hunks interactively
- --ignore-skip-worktree-bits
- do not limit pathspecs to sparse entries only
- --ignore-other-worktrees
- do not check if another worktree is holding the given ref
11、git merge
- qiaozhiguang@XSLUser[master*]$git merge -help
- usage: git merge [<options>] [<commit>...]
- or: git merge [<options>] <msg> HEAD <commit>
- or: git merge --abort
- -n do not show a diffstat at the end of the merge
- --stat show a diffstat at the end of the merge
- --summary (synonym to --stat)
- --log[=<n>] add (at most <n>) entries from shortlog to merge commit message
- --squash create a single commit instead of doing a merge
- --commit perform a commit if the merge succeeds (default)
- -e, --edit edit message before committing
- --ff allow fast-forward (default)
- --ff-only abort if fast-forward is not possible
- --rerere-autoupdate update the index with reused conflict resolution if possible
- --verify-signatures Verify that the named commit has a valid GPG signature
- -s, --strategy <strategy>
- merge strategy to use
- -X, --strategy-option <option=value>
- option for selected merge strategy
- -m, --message <message>
- merge commit message (for a non-fast-forward merge)
- -v, --verbose be more verbose
- -q, --quiet be more quiet
- --abort abort the current in-progress merge
- --progress force progress reporting
- -S, --gpg-sign[=<key-id>]
- GPG sign commit
- --overwrite-ignore update ignored files (default)
12、git stash 将当前 修改 压入栈中
- qiaozhiguang@XSLUser[master*]$git stash -help
- error: unknown option for 'stash save': -help
- To provide a message, use git stash save -- '-help'
- usage: git stash list [<options>]
- or: git stash show [<stash>]
- or: git stash drop [-q|--quiet] [<stash>]
- or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
- or: git stash branch <branchname> [<stash>]
- or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
- [-u|--include-untracked] [-a|--all] [<message>]]