git為指定項目設置用戶名密碼


我們如果沒有為項目設置用戶名密碼,那么每次提交都會有提示賬號和密碼輸入:

1.找到你項目的半隱藏文件.git文件夾,通常只要git init 就會生成這樣一個文件夾,現在雙擊進入文件夾:

git config user.name "qianxiao"

2.我們執行如下代碼查看git配置文件:

cat config
Linux用法

windows 直接記事本打開即可

3.顯示如下配置:

顯示如下內容:

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = http://gitee.com/xxx/object.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "room"]
        remote = origin
        merge = refs/heads/room
[user]
        name = qianxiao

看到最后一行,成功為當前項目設置了git用戶名

4.然后執行如下代碼新增配置:

git config credential.helper store

5.再執行cat config查看配置:

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = http://gitee.com/xxx/object.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "room"]
        remote = origin
        merge = refs/heads/room
[user]
        name = qianxiao
[credential]
        helper = store

看到最后一行新增如上helper;

6.然后回到項目根目錄,再輸入一遍用戶名密碼,下次就不需要再輸入了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM