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

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

签名设置用户名(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. jmeter性能测试2:基础功能介绍

    对于英语不好的同学建议先改为简体中文再进行使用 1.添加->threads->线程组(控制总体并发)            线程数:虚拟用户数.一个虚拟用户占用一个进程或线程        ...

  2. C++ 中库函数bsearch的简单研究(含示例)

    /**//*bsearch函数声明如下: void *bsearch(const void *key, const void *base, size_t *nelem,                 ...

  3. CSS的常用单位介绍

    ①px: 像素单位:它是英文单词pixel的缩写,意思为像素,即构成图片的每一个点,为图片显示的最小单位.它是一个绝 对尺寸单位,是固定的. ②em: 相对长度单位:它是英文单词emphasize的缩 ...

  4. Java入门基础(变量、操作符与表达式)

    Java入门基础 1. 第一个程序 2.变量(命名.运算.整数/小数/字符串.布尔类型) 3.操作符与表达式(算术/逻辑/关系/赋值/自增/类型转换操作符) HelloWorld! public cl ...

  5. java设计模式5——适配器模式

    java设计模式5--适配器模式 1.结构型模式介绍 1.1.作用 从程序的结构上实现松耦合,从而可以扩大整体的类结构,用来解决更大的问题. 分类: 适配器模式 代理模式 桥接模式 装饰模式 组合模式 ...

  6. Flink与HanLP集成使用

    自然语言处理是机器学习的一个重要分支,在智能翻译.智能问答.舆情监控.ChatOps等都有很好的应用场景,目前比较好的一个开源实现工具是何晗大神的HanLP,主页(http://hanlp.com/) ...

  7. Disk:磁盘管理之LVM和系统磁盘扩容

    简介 小伙伴们好,好久不见,今天想给大家介绍一下关于磁盘管理的方法和心得:磁盘管理可谓运维工作中的重要内容,主要包括磁盘的合理规划以及扩缩容 常用的磁盘管理方法为LVM(Logical Volume ...

  8. Redis 3.2.3: 集群3哨兵模式

    简介 Redis是一个使用ANSI C编写的开源.支持网络.基于内存.可选持久性的键值对存储数据库.从2015年6月开始,Redis的开发由Redis Labs赞助,而2013年5月至2015年6月期 ...

  9. Element ui select 同时获取value和label的值

    html <el-form-item label="单位名称" prop="checkInUnitName"> <el-select v-mo ...

  10. JAVA中的约瑟夫环和猴子王问题

    今天在书上(书名< java程序设计经典300例 >李源编著)看了一个有趣的问题,那就是java版的约瑟夫问题,想必大一的小伙伴们早就用c写过了吧 今天我在复习一下 首先问题是这样的n个人 ...