git 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


git

git 命令安装:


-bash/zsh: git: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install git

# Debian
apt-get install git

# Ubuntu
apt-get install git

# Alpine
apk add git

# Arch Linux
pacman -S git

# Kali Linux
apt-get install git

# CentOS
yum install git

# Fedora
dnf install git

# OS X
brew install git

# Raspbian
apt-get install git

# Dockerfile
dockerfile.run/git

# Docker
docker run cmd.cat/git git

git 命令补充说明:


git 是分布式版本控制系统。 一些子命令(例如 commit、add、branch、checkout、push 等)有自己的使用文档,可以通过 tldr git 子命令访问。


git

git 命令语法:


git  [--version] [--help] [-c name=value]
     [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
     [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
     [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
     <command> [<args>]

git 命令选项:


The most commonly used git commands are:

   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

git 命令实例:


检查 Git 版本

git --version

git 显示一般帮助:

git --help

显示有关 Git 子命令的帮助(例如 cloneaddpushlog 等):

git help subcommand

执行 Git 子命令:

git subcommand

在自定义存储库根路径上执行 Git 子命令:

git -C path/to/repo subcommand

使用给定的配置集执行 Git 子命令:

git -c 'config.key=value' subcommand

git 扩展阅读:




git 命令评论