debian多用户下github git push的配置, 不须要帐号password.
由于debian有多种用户, root和普通的user
所以我把user作为了私有的git仓库用户. 把root超级管理员作为了github的用户.
这样子仅仅须要单独配置两个不同的共用gitconfig就能够通用了.
第一个是root下的配置, 在/root/.gitconfig
[user] name = rainysia email = rainysia@gmail.com [alias] co = checkout br = branch ci = commit st = status last = log -1 HEAD cf = config md = commit --amend dt = difftool mt = mergetool line = log --oneline latest = for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short) [%(committername)]' ls = log --pretty=format:\"%C(yellow)%h %C(blue)%ad %C(red)%d %C(reset)%s %C(green)[%cn]\" --decorate --date=short hist = log --pretty=format:\"%C(yellow)%h %C(red)%d %C(reset)%s %C(green)[%an] %C(blue)%ad\" --topo-order --graph --date=short type = cat-file -t dump = cat-file -p [color] diff = auto status = auto branch = auto [http] sslverify = true [https] sslverify = true
第二个是/home/tom/.gitconfig
[user] name = tom xia email = tomx@***.com [alias] co = checkout br = branch ci = commit st = status last = log -1 HEAD cf = config md = commit --amend dt = difftool mt = mergetool line = log --oneline latest = for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short) [%(committername)]' ls = log --pretty=format:\"%C(yellow)%h %C(blue)%ad %C(red)%d %C(reset)%s %C(green)[%cn]\" --decorate --date=short hist = log --pretty=format:\"%C(yellow)%h %C(red)%d %C(reset)%s %C(green)[%an] %C(blue)%ad\" --topo-order --graph --date=short type = cat-file -t dump = cat-file -p [color] diff = auto status = auto branch = auto
这里仅仅说下github在root下的.
#cd ~/.ssh #ssh-keygen -t rsa -C "username@yourhost"
一直回车ok,也能够自己换地方保存, username就是你的github的用户名了,yourhost就是你注冊的邮箱了.比方我的rainysia@gmail.com
#cat ~/.ssh/id_rsa.pub | ssh username@yourhost `cat >> .ssh/authorized_keys` ssh username@yourhost
登陆github系统。点击右上角的 Account Settings--->SSH Public keys ---> add another public keys
把你本地生成的密钥拷贝到里面(key文本框中), 点击 add key 就ok了
接着打开git ,測试连接是否成功
#ssh -T git@github.com假设提示:Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access. 说明你连接成功了
接下来git clone 自己的代码.
克隆完改动, push的时候会提示输入username和password.我们暂停这一操作
在项目文件夹去改动下,把以下的username换成你的,project_name就是你的github的项目名
#git remote set-url origin git@github.com:username/project_name
或者直接改动项目下.git/config里 [remote "origin"] 的url为 url = git@github.com:username/project_name
这样就能够直接git push了.