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

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

签名设置用户名(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. C++读取MNIST数据集

    MNIST是一个标准的手写字符测试集. Mnist数据集对应四个文件: train-images-idx3-ubyte: training set images  train-labels-idx1- ...

  2. FD_WRITE是如何触发的?

    The FD_WRITE network event is handled slightly differently. An FD_WRITE network event is recorded wh ...

  3. BZOJ 1046 [HAOI2007]上升序列(LIS + 贪心)

    题意: m次询问,问下标最小字典序的长度为x的LIS是什么 n<=10000, m<=1000 思路: 先nlogn求出f[i]为以a[i]开头的LIS长度 然后贪心即可,复杂度nm 我们 ...

  4. O准备如何苟进复赛圈?华为软挑开挂指南(附赛题预测)

    事先声明,这不是华为软挑的软广,我也不是海军. 这篇文章纯粹是心血来潮,原因是去年上传到github的参赛代码,前几天又有两个人star和fork了. 记得star热潮还是去年4月复赛刚结束的那几天, ...

  5. Andriod you must restart adb and eclipse

    今天看着视频 学习着 andriod ,启动 的时候 竟然报错 我试了N种google来的方法,都失效,现在把我的解决方法告诉大家,希望能帮到大家. 首先,我先罗列下我搜到的方法,大家也可以尝试. 1 ...

  6. How to Convert a Class File to a Java File?

    What is a programming language? Before introducing compilation and decompilation, let's briefly intr ...

  7. php面试笔记(4)-php基础知识-流程控制

    本文是根据慕课网Jason老师的课程进行的PHP面试知识点总结和升华,如有侵权请联系我进行删除,email:guoyugygy@163.com 在面试中,考官往往喜欢基础扎实的面试者,而流程控制相关的 ...

  8. centos6.x下使用xinetd管理rsync服务

    系统环境说明:centos6.x,centos7.x下rsync直接可由systemd管理(无需使用xinetd). [root@meinv01 ~]# rpm -qa|grep xinetd [ro ...

  9. 杭电-------2048不容易系列之(4)考新郎(C语言)

    /* 思路:有n位新郎,但是又m位新郎会找错,那么有n-m位新郎会找对,而找对的n-m位新郎的找发就是在 n位新郎中随机找n-m位有多少种排列组合公式有n!/(m!*(n-m!)),而另外找错的新郎则 ...

  10. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

    mongoose报错:DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and wil ...