作用:只区分不同开发人员的身份

一、项目级别/仓库级别:仅在当前本地库范围内有效

签名设置用户名(UserName)和邮箱(User@email),邮箱可以是任意邮箱(无效邮箱也可以)

 git config user.name  UserName
git config user.email User@email

例:用户名xingruyu,邮箱xingruyu@qq.com

zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git config user.name xingruyu zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git config user.email xingruyu@qq.com

信息保存位置:./.git/config 文件
zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ ls -al
total
drwxr-xr-x zhang 2月 : ./
drwxr-xr-x zhang 1月 : ../
drwxr-xr-x zhang 2月 : .git/ zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ cat ./.git/config
[core]
repositoryformatversion =
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[user]
name = xingruyu
email = xingruyu@qq.com zhang@SH-B MINGW64 /c/vm/mygithub (master)

用命令查看用户名和邮箱

zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git config user.name
xingruyu

zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git config user.email
xingruyu@qq.com

zhang@SH-B MINGW64 /c/vm/mygithub (master)

二、系统级别:登录当前操作系统的用户范围

 git config --global user.name  UserName
git config --global user.email User@email

信息保存位置:~/.gitconfig 文件

zhang@SH-B MINGW64 ~
$ git config --global user.name zhangfei zhang@SH-B MINGW64 ~
$ git config --global user.email zhangfei@email.com zhang@SH-B MINGW64 ~
$ cat .gitconfig
[user]
name = zhangfei
email = zhangfei@email.com

查看

 git config --global user.name
git config --global user.email

级别优先级,就近原则:项目级别优先于系统用户级别,二者都有时采用项目级别的签名

如果只有系统用户级别的签名,就以系统用户级别的签名为准,二者都没有不允许

三、记录git几个命令

 git rm --cached  文件名  //用于将暂存区的文件恢复到工作区

   zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git add demo
warning: LF will be replaced by CRLF in demo/hello.txt.
The file will have its original line endings in your working directory zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git status
On branch master No commits yet Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: demo/hello.txt zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git rm --cached demo
fatal: not removing 'demo' recursively without -r zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git status
On branch master No commits yet Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: demo/hello.txt zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git rm --cached demo/hello.txt
rm 'demo/hello.txt' zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git status
On branch master No commits yet Untracked files:
(use "git add <file>..." to include in what will be committed)
demo/ nothing added to commit but untracked files present (use "git add" to track) zhang@SH-B MINGW64 /c/vm/mygithub (master) git commit //文件由缓存区提交到本地库 zhang@SH-B MINGW64 /c/vm/mygithub (master) $ git add demo
warning: LF will be replaced by CRLF in demo/hello.txt.
The file will have its original line endings in your working directory zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git status
On branch master No commits yet Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: demo/hello.txt zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git commit demo/hello.txt
warning: LF will be replaced by CRLF in demo/hello.txt.
The file will have its original line endings in your working directory
[master (root-commit) 030671e] first commit
file changed, insertion(+)
create mode demo/hello.txt zhang@SH-B MINGW64 /c/vm/mygithub (master)
$ git status
On branch master
nothing to commit, working tree clean zhang@SH-B MINGW64 /c/vm/mygithub (master) git restore 文件名字 进行清除工作区的改变,与git add 的作用相反 zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ cat hello.txt
hello.test
modify first zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ vi hello.txt zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ cat hello.txt
hello.test
modify first
modify second zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: hello.txt no changes added to commit (use "git add" and/or "git commit -a") zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ git restore hello.txt zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ git status
On branch master
nothing to commit, working tree clean zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ cat hello.txt
hello.test
modify first zhang@SH-B MINGW64 /c/vm/mygithub/demo (master) git restore --staged <file> //撤销git add 的文件 MINGW64 /c/vm/mygithub/demo (master)
$ git add hello.txt zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: hello.txt zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ git restore --staged hello.txt zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: hello.txt no changes added to commit (use "git add" and/or "git commit -a") zhang@SH-B MINGW64 /c/vm/mygithub/demo (master)

git签名设置的更多相关文章

  1. git 代理设置

    git 代理设置: git config --global http.proxy http://proxy.com:8080git config --global https.proxy http:/ ...

  2. git命令设置简写(别名)

    ### git命令设置简写(别名) 前言:有时候在执行git命令比较多的情况下,每次敲git命令比较费时,同时有些命令比如cherry-pick这种比较长时更是费时,所以可以通过设置命令行简写来设置. ...

  3. git Alias 设置

    git Alias 设置 Git 使用比較多的话能够设置一些命令的 Alias ,简单的说就是用简写取代整个完整的命令. 如co 代表 checkout. Mac下,到根文件夹 cd ~ 然后 vi ...

  4. Jenkins Git安装设置

    Jenkins Git安装设置 在此安装中,必须确保Internet连接可连接其安装 Jenkins 机器.在 Jenkins 仪表盘(主屏幕)的左侧单击 Manage Jenkins 选项.打开网址 ...

  5. VS Code 提示‘未找到Git。请安装Git,或在“git.path”设置中配置’

    一.情况说明 1.描述 从Git上克隆出代码,用vscode打开项目提示“未找到Git.请安装Git,或在“git.path”设置中配置” 2.截图 二.报错原因 .没有安装Git .没有设置Git路 ...

  6. go get 无反应方法 Win/Linux 命令行、终端和 Git 代理设置

    go get -u -v 无反应方法 CMD要用管理员权限运行,否则设置无效 netsh winhttp set proxy proxy-server="https=127.0.0.1:10 ...

  7. git中设置代理

    说明:在某种原因下,整个网络都是使用代理的情况下,需要使用git clone,这时就需要设置代理了. 在没有设置代理的时候,直接克隆报错  Failed to connect to gitee.com ...

  8. vscode源代码管理(vscode报错 未找到Git,请安装Git,或在"git.path" 设置中配置)

    vscode源代码管理(vscode报错 未找到Git,请安装Git,或在"git.path" 设置中配置) 直接上图,电脑上已经安装git,由于vscode没有找到git,所以v ...

  9. 取消Git代理设置

    昨天由于在用sourceTree上传下拉代码的时候,速度实在太慢,就照着百度上的方法设置了代理,结果导致sourceTree无法访问服务器,经检查排除发现可能是因为公司网络不能使用代理,被防火墙挡住了 ...

随机推荐

  1. 17、Wireless

    1. WLAN在物理层采用的是无线电 i.    wlan采用csma/ca代替lan的csma/cd ii.    工作在半双工模式,共享带宽(无法在发送的同时接收信号) 2. WLAN会遇到的问题 ...

  2. [css]画圆形标签

    画圆形标签的窍门: 圆形是在padding和margin中间同时是padding的内切圆也是margin的外接圆 .circle{ width: 20px; height: 20px; display ...

  3. Codeforces_734_C

    http://codeforces.com/problemset/problem/734/C 枚举第一种,二分第二种,注意不取的情况. #include<iostream> #includ ...

  4. 微信小程序—Flex布局

    参考教程:http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html     https://xluos.github.io/demo/flexb ...

  5. WSL2+Docker部署RabbitMQ以及在Asp.net core 中使用RabbitMQ示例(1)

    本文主要在于最近因疫情不能外出,在家研究的一些技术积累. 主要用到的技术以及知识点: WSL 2 WSL 2+Docker Docker+RabbitMQ 在ASP.NET Core中使用Rabbit ...

  6. 用反射、泛型 改造SqlHelper

    1.  数据准备 public class BaseModel { public int Id { set; get; } } public class Company : BaseModel { p ...

  7. SNMP协议交互学习-获取udp的udpindatagrams

    MIB的组织结构,如下左图,对于udp来说1.3.6.1.2.1.7,组织如下右图,包括4个标量和1个表格 udp节点在LwIP中的定义如下: ] = { , , , , }; ] = { (stru ...

  8. DeBug Python神级工具PySnooper

    安装 pip3 install pysnooper import pysnooper @pysnooper.snoop() def number_to_bits(number): if number: ...

  9. aliyun---ossutil

    上传文件: ossutil -c config cp -rf 源文件 oss://目标路径 config为存储key的文件 例子: ossutil -c config cp -rf /data/res ...

  10. Linux 配置 DNS

    这里不讨论如何在linux上搭建一台DNS服务器: 这里讨论的是 配置 linux系统,让其能够解析域名,使用户可以流畅使用Internet 先了解几个文件,位于/etc目录下的有:hosts,hos ...