Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git_2 Git 配置(git config) #62

Open
Qingquan-Li opened this issue Oct 7, 2017 · 0 comments
Open

Git_2 Git 配置(git config) #62

Qingquan-Li opened this issue Oct 7, 2017 · 0 comments
Labels

Comments

@Qingquan-Li
Copy link
Owner

Qingquan-Li commented Oct 7, 2017

获取帮助

若你使用 Git 时需要获取帮助,有三种方法可以找到 Git 命令的使用手册:

  • git help <verb>
  • git <verb> --help
  • man git-<verb>

例如,要想获得 config 命令的手册,执行 git help config


初次运行 Git 前的配置

Git 自带一个 git config 的工具来帮助设置控制 Git 外观和行为的配置变量。

配置用户信息

当安装完 Git 应该做的第一件事就是设置你的用户名称邮件地址。 这样做很重要,因为每一个 Git 的提交都会使用这些信息,并且它会写入到你的每一次提交中,不可更改:

  • git config --global user.name "userName"
  • git config --global user.email xxx@example.com

再次强调,如果使用了 --global 选项,那么该命令只需要运行一次,因为之后无论你在该系统上做任何事情, Git 都会使用那些信息。 当你想针对特定项目使用不同的用户名称与邮件地址时,可以在那个项目目录下运行没有 --global 选项的命令来配置。

检查配置信息

  • 使用 git config --list 命令来列出所有 Git 当时能找到的配置。

    $ git config --list
    credential.helper=osxkeychain
    user.name=李庆权
    user.email=liqqisme@gmail.com
  • 使用 git config <key> 来检查 Git 的某一项配置

    $ git config user.name
    李庆权

注意

只要配置了 user.email=GitHub注册邮箱,提交代码到 Github 时就会显示提交者是当前 GitHub 用户。

$ vim ~/.gitconfig
# or: $ git config --global --edit

# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
# name = Qingquan Li  # default use system username on macOS
email = liqqisme@gmail.com  # GitHub Email
@Qingquan-Li Qingquan-Li changed the title Git_2 起步 - Git 配置 Git_2 Git 配置 Oct 7, 2017
@Qingquan-Li Qingquan-Li added the Git label Oct 7, 2017
@Qingquan-Li Qingquan-Li changed the title Git_2 Git 配置 Git_2 Git 配置(git config) Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant