前端analysis | 3w & 1h

《 Git 》 - Git日常开发命令从入门到精通

2020-07-02

Git 安装

点击链接,下载不同的版本安装即可,这里不再赘述了。

1
2
3
4
5
6
7
8
9
 $ git 
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]

These are common Git commands used in various situations:
....

Git 配置

git config

Get and set repository or global options

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ git config --help 
git config [<file-option>] [--type=<type>] [--show-origin] [-z|--null] name [value [value_regex]]
git config [<file-option>] [--type=<type>] --add name value
git config [<file-option>] [--type=<type>] --replace-all name value [value_regex]
git config [<file-option>] [--type=<type>] [--show-origin] [-z|--null] --get name [value_regex]
git config [<file-option>] [--type=<type>] [--show-origin] [-z|--null] --get-all name [value_regex]
git config [<file-option>] [--type=<type>] [--show-origin] [-z|--null] [--name-only] --get-regexp name_regex [value_regex]
git config [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch name URL
git config [<file-option>] --unset name [value_regex]
git config [<file-option>] --unset-all name [value_regex]
git config [<file-option>] --rename-section old_name new_name
git config [<file-option>] --remove-section name
git config [<file-option>] [--show-origin] [-z|--null] [--name-only] -l | --list
git config [<file-option>] --get-color name [default]
git config [<file-option>] --get-colorbool name [stdout-is-tty]
git config [<file-option>] -e | --edit

查看配置所在文件.git/config

1
2
3
4
5
6
7
8
9
10
11
12
13
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/xxx.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

修改配置项

1
git config core.filemode true

总结

  • git 配置文件,配置存在分组概念。譬如core,remote ,branch 这些
  • 每个分组的内容,通过key-value形式覆盖,中间空格连接 。core.filemodel true

Git 项目 管理

git init

Create an empty Git repository or reinitialize an existing one

git clone

Clone a repository into a new directory

  • 更新所有的本地fork分支
    1
    git fetch
  • 拉取remote分支到当前分支
    1
    2
    # 拉取remote分支,在.git/config 中remote中配置指定
    git pull

    Git code 管理

    Git code version管理

Tags: git
使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏