常用 git 命令使用说明(-help)汇总

来源:互联网 发布:gradle linux 安装 编辑:程序博客网 时间:2024/06/05 05:45

1、克隆远程代码库 git clone

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git clone -help  
  2. usage: git clone [<options>] [--] <repo> [<dir>]  
  3.   
  4.     -v, --verbose         be more verbose  
  5.     -q, --quiet           be more quiet  
  6.     --progress            force progress reporting  
  7.     -n, --no-checkout     don't create a checkout  
  8.     --bare                create a bare repository  
  9.     --mirror              create a mirror repository (implies bare)  
  10.     -l, --local           to clone from a local repository  
  11.     --no-hardlinks        don't use local hardlinks, always copy  
  12.     -s, --shared          setup as shared repository  
  13.     --recursive           initialize submodules in the clone  
  14.     --recurse-submodules  initialize submodules in the clone  
  15.     --template <template-directory>  
  16.                           directory from which templates will be used  
  17.     --reference <repo>    reference repository  
  18.     --dissociate          use --reference only while cloning  
  19.     -o, --origin <name>   use <name> instead of 'origin' to track upstream  
  20.     -b, --branch <branch>  
  21.                           checkout <branch> instead of the remote's HEAD  
  22.     -u, --upload-pack <path>  
  23.                           path to git-upload-pack on the remote  
  24.     --depth <depth>       create a shallow clone of that depth  
  25.     --single-branch       clone only one branch, HEAD or --branch  
  26.     --separate-git-dir <gitdir>  
  27.                           separate git dir from working tree  
  28.     -c, --config <key=value>  
  29.                           set config inside the new repository  



2、创建本地代码仓库 git init

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git init -help  
  2. usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]  
  3.   
  4.     --template <template-directory>  
  5.                           directory from which templates will be used  
  6.     --bare                create a bare repository  
  7.     --shared[=<permissions>]  
  8.                           specify that the git repository is to be shared amongst several users  
  9.     -q, --quiet           be quiet  
  10.     --separate-git-dir <gitdir>  
  11.                           separate git dir from working tree  

3、添加命令 git add

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git add -help  
  2. usage: git add [<options>] [--] <pathspec>...  
  3.   
  4.     -n, --dry-run         dry run  
  5.     -v, --verbose         be verbose  
  6.   
  7.     -i, --interactive     interactive picking  
  8.     -p, --patch           select hunks interactively  
  9.     -e, --edit            edit current diff and apply  
  10.     -f, --force           allow adding otherwise ignored files  
  11.     -u, --update          update tracked files  
  12.     -N, --intent-to-add   record only the fact that the path will be added later  
  13.     -A, --all             add changes from all tracked and untracked files  
  14.     --ignore-removal      ignore paths removed in the working tree (same as --no-all)  
  15.     --refresh             don't add, only refresh the index  
  16.     --ignore-errors       just skip files which cannot be added because of errors  
  17.     --ignore-missing      check if - even missing - files are ignored in dry run  

4, git tag 标签命令

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git tag -help  
  2. usage: git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <tagname> [<head>]  
  3.    or: git tag -d <tagname>...  
  4.    or: git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]  
  5.         [<pattern>...]  
  6.    or: git tag -v <tagname>...  
  7.   
  8.     -l, --list            list tag names  
  9.     -n[<n>]               print <n> lines of each tag message  
  10.     -d, --delete          delete tags  
  11.     -v, --verify          verify tags  
  12.   
  13. Tag creation options  
  14.     -a, --annotate        annotated tag, needs a message  
  15.     -m, --message <message>  
  16.                           tag message  
  17.     -F, --file <file>     read message from file  
  18.     -s, --sign            annotated and GPG-signed tag  
  19.     --cleanup <mode>      how to strip spaces and #comments from message  
  20.     -u, --local-user <key-id>  
  21.                           use another key to sign the tag  
  22.     -f, --force           replace the tag if exists  
  23.   
  24. Tag listing options  
  25.     --column[=<style>]    show tag list in columns  
  26.     --sort <type>         sort tags  
  27.     --contains <commit>   print only tags that contain the commit  
  28.     --points-at <object>  print only tags of the object  

5、git pull 拉取远程代码仓库,并与本地代码仓库 merge

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git pull -help  
  2. usage: git pull [options] [<repository> [<refspec>...]]  
  3.   
  4.     Fetch one or more remote refs and integrate it/them with the current HEAD.  
  5.   
  6.     -v, --verbose         be more verbose  
  7.     -q, --quiet           be more quiet  
  8.     --progress            force progress reporting  
  9.   
  10. Options related to merging  
  11.     -r, --rebase[=<false|true|preserve>]  
  12.                           incorporate changes by rebasing rather than merging  
  13.     -n                    do not show a diffstat at the end of the merge  
  14.     --stat                show a diffstat at the end of the merge  
  15.     --summary             (synonym to --stat)  
  16.     --log[=<n>]           add (at most <n>) entries from shortlog to merge commit message  
  17.     --squash              create a single commit instead of doing a merge  
  18.     --commit              perform a commit if the merge succeeds (default)  
  19.     -e, --edit            edit message before committing  
  20.     --ff                  allow fast-forward  
  21.     --ff-only             abort if fast-forward is not possible  
  22.     --verify-signatures   verify that the named commit has a valid GPG signature  
  23.     -s, --strategy <strategy>  
  24.                           merge strategy to use  
  25.     -X, --strategy-option <option>  
  26.                           option for selected merge strategy  
  27.     -S, --gpg-sign[=<key-id>]  
  28.                           GPG sign commit  
  29.   
  30. Options related to fetching  
  31.     --all                 fetch from all remotes  
  32.     -a, --append          append to .git/FETCH_HEAD instead of overwriting  
  33.     --upload-pack <path>  path to upload pack on remote end  
  34.     -f, --force           force overwrite of local branch  
  35.     -t, --tags            fetch all tags and associated objects  
  36.     -p, --prune           prune remote-tracking branches no longer on remote  
  37.     --recurse-submodules[=<on-demand>]  
  38.                           control recursive fetching of submodules  
  39.     --dry-run             dry run  
  40.     -k, --keep            keep downloaded pack  
  41.     --depth <depth>       deepen history of shallow clone  
  42.     --unshallow           convert to a complete repository  
  43.     --update-shallow      accept refs that update .git/shallow  
  44.     --refmap <refmap>     specify fetch refmap  

6、git push 将本地代码仓库 推送到远程代码仓库

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git push -help  
  2. usage: git push [<options>] [<repository> [<refspec>...]]  
  3.   
  4.     -v, --verbose         be more verbose  
  5.     -q, --quiet           be more quiet  
  6.     --repo <repository>   repository  
  7.     --all                 push all refs  
  8.     --mirror              mirror all refs  
  9.     --delete              delete refs  
  10.     --tags                push tags (can't be used with --all or --mirror)  
  11.     -n, --dry-run         dry run  
  12.     --porcelain           machine-readable output  
  13.     -f, --force           force updates  
  14.     --force-with-lease[=<refname>:<expect>]  
  15.                           require old value of ref to be at this value  
  16.     --recurse-submodules[=<check|on-demand>]  
  17.                           control recursive pushing of submodules  
  18.     --thin                use thin pack  
  19.     --receive-pack <receive-pack>  
  20.                           receive pack program  
  21.     --exec <receive-pack>  
  22.                           receive pack program  
  23.     -u, --set-upstream    set upstream for git pull/status  
  24.     --progress            force progress reporting  
  25.     --prune               prune locally removed refs  
  26.     --no-verify           bypass pre-push hook  
  27.     --follow-tags         push missing but relevant tags  
  28.     --signed              GPG sign the push  
  29.     --atomic              request atomic transaction on remote side  

7、查看状态 git  status

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git status -help  
  2. usage: git status [<options>] [--] <pathspec>...  
  3.   
  4.     -v, --verbose         be verbose  
  5.     -s, --short           show status concisely  
  6.     -b, --branch          show branch information  
  7.     --porcelain           machine-readable output  
  8.     --long                show status in long format (default)  
  9.     -z, --null            terminate entries with NUL  
  10.     -u, --untracked-files[=<mode>]  
  11.                           show untracked files, optional modes: all, normal, no. (Default: all)  
  12.     --ignored             show ignored files  
  13.     --ignore-submodules[=<when>]  
  14.                           ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)  
  15.     --column[=<style>]    list untracked files in columns  

8、git commit

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git commit -help  
  2. usage: git commit [<options>] [--] <pathspec>...  
  3.   
  4.     -q, --quiet           suppress summary after successful commit  
  5.     -v, --verbose         show diff in commit message template  
  6.   
  7. Commit message options  
  8.     -F, --file <file>     read message from file  
  9.     --author <author>     override author for commit  
  10.     --date <date>         override date for commit  
  11.     -m, --message <message>  
  12.                           commit message  
  13.     -c, --reedit-message <commit>  
  14.                           reuse and edit message from specified commit  
  15.     -C, --reuse-message <commit>  
  16.                           reuse message from specified commit  
  17.     --fixup <commit>      use autosquash formatted message to fixup specified commit  
  18.     --squash <commit>     use autosquash formatted message to squash specified commit  
  19.     --reset-author        the commit is authored by me now (used with -C/-c/--amend)  
  20.     -s, --signoff         add Signed-off-by:  
  21.     -t, --template <file>  
  22.                           use specified template file  
  23.     -e, --edit            force edit of commit  
  24.     --cleanup <default>   how to strip spaces and #comments from message  
  25.     --status              include status in commit message template  
  26.     -S, --gpg-sign[=<key-id>]  
  27.                           GPG sign commit  
  28.   
  29. Commit contents options  
  30.     -a, --all             commit all changed files  
  31.     -i, --include         add specified files to index for commit  
  32.     --interactive         interactively add files  
  33.     -p, --patch           interactively add changes  
  34.     -o, --only            commit only specified files  
  35.     -n, --no-verify       bypass pre-commit hook  
  36.     --dry-run             show what would be committed  
  37.     --short               show status concisely  
  38.     --branch              show branch information  
  39.     --porcelain           machine-readable output  
  40.     --long                show status in long format (default)  
  41.     -z, --null            terminate entries with NUL  
  42.     --amend               amend previous commit  
  43.     --no-post-rewrite     bypass post-rewrite hook  
  44.     -u, --untracked-files[=<mode>]  
  45.                           show untracked files, optional modes: all, normal, no. (Default: all)  

9、git branch

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git branch -help  
  2. usage: git branch [<options>] [-r | -a] [--merged | --no-merged]  
  3.    or: git branch [<options>] [-l] [-f] <branch-name> [<start-point>]  
  4.    or: git branch [<options>] [-r] (-d | -D) <branch-name>...  
  5.    or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>  
  6.   
  7. Generic options  
  8.     -v, --verbose         show hash and subject, give twice for upstream branch  
  9.     -q, --quiet           suppress informational messages  
  10.     -t, --track           set up tracking mode (see git-pull(1))  
  11.     --set-upstream        change upstream info  
  12.     -u, --set-upstream-to <upstream>  
  13.                           change the upstream info  
  14.     --unset-upstream      Unset the upstream info  
  15.     --color[=<when>]      use colored output  
  16.     -r, --remotes         act on remote-tracking branches  
  17.     --contains <commit>   print only branches that contain the commit  
  18.     --abbrev[=<n>]        use <n> digits to display SHA-1s  
  19.   
  20. Specific git-branch actions:  
  21.     -a, --all             list both remote-tracking and local branches  
  22.     -d, --delete          delete fully merged branch  
  23.     -D                    delete branch (even if not merged)  
  24.     -m, --move            move/rename a branch and its reflog  
  25.     -M                    move/rename a branch, even if target exists  
  26.     --list                list branch names  
  27.     -l, --create-reflog   create the branch's reflog  
  28.     --edit-description    edit the description for the branch  
  29.     -f, --force           force creation, move/rename, deletion  
  30.     --no-merged <commit>  print only not merged branches  
  31.     --merged <commit>     print only merged branches  
  32.     --column[=<style>]    list branches in columns  


10,git checkout

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git checkout -help  
  2. usage: git checkout [<options>] <branch>  
  3.    or: git checkout [<options>] [<branch>] -- <file>...  
  4.   
  5.     -q, --quiet           suppress progress reporting  
  6.     -b <branch>           create and checkout a new branch  
  7.     -B <branch>           create/reset and checkout a branch  
  8.     -l                    create reflog for new branch  
  9.     --detach              detach the HEAD at named commit  
  10.     -t, --track           set upstream info for new branch  
  11.     --orphan <new-branch>  
  12.                           new unparented branch  
  13.     -2, --ours            checkout our version for unmerged files  
  14.     -3, --theirs          checkout their version for unmerged files  
  15.     -f, --force           force checkout (throw away local modifications)  
  16.     -m, --merge           perform a 3-way merge with the new branch  
  17.     --overwrite-ignore    update ignored files (default)  
  18.     --conflict <style>    conflict style (merge or diff3)  
  19.     -p, --patch           select hunks interactively  
  20.     --ignore-skip-worktree-bits  
  21.                           do not limit pathspecs to sparse entries only  
  22.     --ignore-other-worktrees  
  23.                           do not check if another worktree is holding the given ref  


11、git merge

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. qiaozhiguang@XSLUser[master*]$git merge -help  
  2. usage: git merge [<options>] [<commit>...]  
  3.    or: git merge [<options>] <msg> HEAD <commit>  
  4.    or: git merge --abort  
  5.   
  6.     -n                    do not show a diffstat at the end of the merge  
  7.     --stat                show a diffstat at the end of the merge  
  8.     --summary             (synonym to --stat)  
  9.     --log[=<n>]           add (at most <n>) entries from shortlog to merge commit message  
  10.     --squash              create a single commit instead of doing a merge  
  11.     --commit              perform a commit if the merge succeeds (default)  
  12.     -e, --edit            edit message before committing  
  13.     --ff                  allow fast-forward (default)  
  14.     --ff-only             abort if fast-forward is not possible  
  15.     --rerere-autoupdate   update the index with reused conflict resolution if possible  
  16.     --verify-signatures   Verify that the named commit has a valid GPG signature  
  17.     -s, --strategy <strategy>  
  18.                           merge strategy to use  
  19.     -X, --strategy-option <option=value>  
  20.                           option for selected merge strategy  
  21.     -m, --message <message>  
  22.                           merge commit message (for a non-fast-forward merge)  
  23.     -v, --verbose         be more verbose  
  24.     -q, --quiet           be more quiet  
  25.     --abort               abort the current in-progress merge  
  26.     --progress            force progress reporting  
  27.     -S, --gpg-sign[=<key-id>]  
  28.                           GPG sign commit  
  29.     --overwrite-ignore    update ignored files (default)  

12、git stash 将当前 修改 压入栈中 

[objc] view plain copy
  1. qiaozhiguang@XSLUser[master*]$git stash -help  
  2. error: unknown option for 'stash save': -help  
  3.        To provide a message, use git stash save -- '-help'  
  4. usage: git stash list [<options>]  
  5.    or: git stash show [<stash>]  
  6.    or: git stash drop [-q|--quiet] [<stash>]  
  7.    or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]  
  8.    or: git stash branch <branchname> [<stash>]  
  9.    or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]  
  10.                [-u|--include-untracked] [-a|--all] [<message>]]  





0 0
原创粉丝点击