欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Git配置用戶簽名方式的拓展示例實現(xiàn)全面講解

 更新時間:2022年04月24日 11:04:33   作者:繁華似錦Fighting  
這篇文章主要為大家介紹了Git配置用戶簽名方式的拓展示例實現(xiàn)全面講解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

1、配置Git簽名

(1)語法

$ git config 配置文件作用域 user.name '用戶名'
$ git config 配置文件作用域 user.email '郵箱地址'

示例如下:

配置 user.name和user.email
$ git config --global user.name ‘your_name'
$ git config --global user.email ‘your_email@domain.com'

注意:這個email一定是有效的,是你能夠收得到郵件的email。

(2)配置系統(tǒng)用戶簽名

可在任意目錄下運行創(chuàng)建命令:git config --system

L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ git config --system user.name 'tang_s'
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ git config --system user.email 'tang_s@126.com'

提示:在Git中,沒有提示就是最好的提示。

系統(tǒng)用戶注冊信息會寫在本地Git的安裝目錄下,...\etc\gitconfig文件中。

L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ cat /f/DevInstall/Git/GitforWindows/etc/gitconfig
[diff "astextplain"]
        textconv = astextplain
[filter "lfs"]
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
        required = true
[http]
        sslBackend = openssl
        sslCAInfo = F:/DevInstall/Git/GitforWindows/mingw64/ssl/certs/ca-bundle.crt
[core]
        autocrlf = true
        fscache = true
        symlinks = false
[credential]
        helper = manager
[user]
        name = tang_s
        email = tang_s@126.com

提示:之前的Git版本中,gitconfig文件是在,Git安裝目錄下mingw64目錄中的etc/gitconfig

(3)配置全局用戶簽名

可在任意目錄下運行創(chuàng)建命令:git config --global

# 在任何位置執(zhí)行都可以
# 執(zhí)行這個配置表示你這臺機器上所有的Git倉庫都會使用這個配置,
# 當然也可以對某個倉庫指定不同的用戶名和Email地址(本地用戶)。
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ git config --global user.name 'sun_wk'
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ git config --global user.email 'sun_wk@126.com'

全局用戶注冊的信息,會寫到當前用戶目錄下.gitconfig文件中。

L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ cat /c/Users/L/.gitconfig
[user]
        name = sun_wk
        email = sun_wk@126.com

(4)配置本地用戶簽名

本地庫用戶只能在當前的本地庫目錄下運行該命令:

# 注意如果是配置local配置文件簽名,可以省略--local參數(shù)
$ git config --local user.name 'sha_hs'
$ git config --local user.email 'sha_hs@126.com'

注意:

執(zhí)行上邊命令,要在一個倉庫中執(zhí)行,否則會提示你:

fatal: --local can only be used inside a git repository

還有--local選項只能在Git倉庫中使用。

演示:

# 此時learngit目錄不是一個本地Git倉庫
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ git config --local user.name ''
fatal: --local can only be used inside a git repository
# 初始化learngit目錄為Git本地倉庫
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit
$ git init
Initialized empty Git repository in J:/git-repository/learngit/.git/
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
# 配置本地用戶簽名
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ git config --local user.name 'sha_hs'
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ git config --local user.email 'sha_hs@126.com'

本地用戶注冊信息,會寫到當前版本庫目錄下的.git目錄中的config文件中。

L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[user]
        name = sha_hs
        email = sha_hs@126.com

注意:

  • 簽名設置的用戶名和郵箱,主要作用就是區(qū)分不同開發(fā)人員的身份。
  • 這里設置的簽名和登錄遠程庫,也就是代碼托管中心的賬號、密碼沒有任何關系。
  • Email地址沒有要求和用戶名一致,甚至Email地址不存在都沒事。
  • 但是在實際工作中,這個Email一定是有效的,是你能夠收得到郵件的Email。

2、查看三個配置文件的用戶簽名

通過命令的方式查看三個配置文件的用戶簽名。

(1)語法

執(zhí)行git config命令,來查看各作用域配置文件中的配置信息。(這個命令在任何路徑下都能執(zhí)行)

只執(zhí)行git config命令,會顯示git config命令所有的可用參數(shù)。

執(zhí)行git config --list命令,查看當前系統(tǒng)中Git的所有配置,三個配置文件所有的配置都顯示出來。

查看指定指定配置文件的內(nèi)容:

執(zhí)行語句說明
$ git config --list --local查看項目/倉庫級別的配置文件信息
$ git config --list --global查看用戶級別配置文件信息
$ git config --list --system查看系統(tǒng)級別配置文件信息

(2)查看項目/倉庫級別的配置文件信息(local)

需要進入到一個倉庫中,執(zhí)行$ git config --list --local命令,才能顯示該倉庫的配置信息。否則會出現(xiàn)提示

fatal: --local can only be used inside a git repository,

--local選項只能在Git倉庫中使用。

L@DESKTOP-T2AI2SU MINGW64 /j/git-repository
$ git config --list --local
fatal: --local can only be used inside a git repository
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository
$ cd learngit/
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ git config --list --local
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
user.name=sha_hs
user.email=sha_hs@126.com

提示:

執(zhí)行$ git config --list --local命令時, Git會讀取倉庫中.git目錄下的.git/config配置文件,該文件含有當前倉庫的配置信息。

# 查看.git目錄
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ ll .git/
total 7
-rw-r--r-- 1 L 197121 176  4月  2 22:43 config
-rw-r--r-- 1 L 197121  73  4月  2 22:41 description
-rw-r--r-- 1 L 197121  23  4月  2 22:41 HEAD
drwxr-xr-x 1 L 197121   0  4月  2 22:41 hooks/
drwxr-xr-x 1 L 197121   0  4月  2 22:41 info/
drwxr-xr-x 1 L 197121   0  4月  2 22:41 objects/
drwxr-xr-x 1 L 197121   0  4月  2 22:41 refs/
# 查看.git/config文件中的內(nèi)容
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ cat .git/config
[core]
     repositoryformatversion = 0
     filemode = false
     bare = false
     logallrefupdates = true
     symlinks = false
     ignorecase = true
[user]
     name = sha_hs
     email = sha_hs@126.com

(3)查看用戶/全局級別的配置文件信息(global)

在任何位置執(zhí)行$ git config --list --global命令即可。

# 任何目錄下執(zhí)行都可以
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ git config --list --global
user.name=sun_wk
user.email=sun_wk@126.com

注意:

如果我們是新安裝的Git,還沒有配置過global作用域內(nèi)的配置信息,global級別的配置文件是沒有的,只有我們配置一次global級別的配置信息,配置文件才會生成。

fatal: unable to read config file 'C:/Users/L/.gitconfig': No such file or directory

提示你無法讀取配置文件'C:/Users/L/.gitconfig':沒有此類文件或目錄。

提示:

當我們配置過global作用域中的信息后,C:/Users/L/中的.gitconfig文件出現(xiàn)了。

執(zhí)行git config --list --global命令后,查看的就是C:/Users/L/.gitconfig文件中的內(nèi)容。

(4)查看系統(tǒng)級別的配置文件信息(system)

在任何位置執(zhí)行$ git config --list --system命令即可。

演示:

L@DESKTOP-T2AI2SU MINGW64 /j/git-repository
$ git config --list --system
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=F:/DevInstall/Git/GitforWindows/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=tang_s
user.email=tang_s@126.com

提示:

該命令讀取的配置文件所在的位置是,Git安裝目錄下的etc目錄中的gitconfig文件。

查看gitconfig文件中的內(nèi)容,與上邊顯示的內(nèi)容是對應的。

(5)查看當前系統(tǒng)中Git的所有配置信息

執(zhí)行git config --list命令,查看當前系統(tǒng)中Git的所有配置,上面三個配置文件所有的配置都顯示出來。

示例:

# 如果沒有再本地倉庫中執(zhí)行該命令,只顯示系統(tǒng)用戶和全局用戶配置文件中的信息
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository
$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=F:/DevInstall/Git/GitforWindows/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=tang_s    # 系統(tǒng)用戶簽名
user.email=tang_s@126.com
user.name=sun_wk	# 全局用戶簽名
user.email=sun_wk@126.com
# 如果在本地倉庫中執(zhí)行該命令,三種用戶配置文件的信息都會顯示出來
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository
$ cd learngit/
L@DESKTOP-T2AI2SU MINGW64 /j/git-repository/learngit (master)
$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=F:/DevInstall/Git/GitforWindows/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=tang_s    # 系統(tǒng)用戶簽名
user.email=tang_s@126.com
user.name=sun_wk  	# 全局用戶簽名
user.email=sun_wk@126.com
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
user.name=sha_hs	# 本地用戶簽名
user.email=sha_hs@126.com

3、總結

  • 在本地Git的安裝目錄下,etc\gitconfig文件:是對登陸該操作系統(tǒng)的所有用戶都普遍適用的配置。若使用git config命令時加上--system選項,讀寫的就是這個文件中的內(nèi)容。
  • 當前操作系統(tǒng)用戶目錄下.gitconfig文件:該配置文件只適用于該用戶,該用戶可以配置Git用戶簽名等信息到這個配置文件中,是對這臺計算機上所有的Git倉庫適用。若使用git config命令時加上--global選項,讀寫的就是這個文件中的內(nèi)容。
  • Git本地倉庫中.git/config文件:當前項目的Git本地倉庫中的配置文件,文件中的配置僅僅針對當前項目倉庫有效。

提示:每一個級別的配置都會覆蓋上層的相同配置。(local覆蓋global覆蓋system

以上就是Git配置用戶簽名方式的拓展示例實現(xiàn)全面講解的詳細內(nèi)容,更多關于Git配置用戶簽名方式的資料請關注腳本之家其它相關文章!

相關文章

最新評論