git基本命令-配置

1、查看git所有配置项

$ git config -l

$ git config --list

2、全局配置用账号、密码、邮箱、仓库地址

$git config --global user.name "young"

$git config --global user.password "xxxxxxxx"

$git config --global user.email "[email protected]"

$git config --global remote.origin.url=https://[email protected]/***.git

git config credential.helper store // 记住密码

git config --system --unset credential.helper // 清理用户名和密码

3、下载仓库到本地

$git clone 仓库地址

4、提交本地仓库下的文件

$cd 进入要提交的目录

$git init

$git add .

$git commit -m "提交文字描述"

$git push


遇到问题及解决方案:

1、需要使用个人访问令牌提交:You must use a personal access token

(1)、登录Github,找到右上角的图标,打开点进里面的Settings,再选中里面的Access Tokens,Add a Personal Access Tokens

(2)、复制并保存Access Token

(3)、清理用户名和密码:git config --system --unset credential.helper(如果出现权限问题,将git安装目录下的etc的everyone用户权限设置完全控制,linux下用sudo)

(4)、使用Access Token代替用户密码

2、单个文件超过最大大小(web服务器限制): RPC failed; HTTP 413 curl 22 The requested URL returned error: 413

解决方法:解决方法其实能通过ssh提交来解决。(也可以通过web服务器配置来解决)

(1)、生成秘钥:ssh-keygen –t rsa –C “[email protected]“(改为自己的登录邮箱)// 在git命令行执行

(2)、复制公钥到剪切板:clip < ~/.ssh/id_rsa.pub

(3)、在我们git的账户中添加ssh公钥:登录Github,找到右上角的图标,打开点进里面的Settings,再选中里面的SSH and GPG KEYS,将公钥字符串粘贴到SSH Keys框中。

(4)、将remote.origin.url参数值设置为ssh的地址,如:ssh://[email protected]:30022/abc.git


配置参数解析

[email protected]

user.name=leo

core.ignorecase=false            # 不许忽略文件名大小写

core.autocrlf=input              # 换行模式为 input,即提交时转换为LF,检出时不转换

core.filemode=false              # 不检查文件权限

core.safecrlf=true              # 拒绝提交包含混合换行符的文件

core.editor=vim

core.repositoryformatversion=0  # Internal variable identifying the repository format and layout version

core.bare=false                  # 默认不创建裸仓库

core.logallrefupdates=true      # log 所有 ref 的更新

core.precomposeunicode=true      # Mac专用选项,开启以便文件名兼容其他系统

push.default=simple                    # 只推送本地当前分支,且与上游分支名字一致

alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

pull.rebase=true                # 强制开启 rebase 模式

credential.helper store // 记住密码

// 推荐配置

git config --global user.email “[email protected]"

git config --global user.name=mtide

sudo git config --system core.ignorecase false

sudo git config --system core.autocrlf input

sudo git config --system core.filemode false

sudo git config --system core.safecrlf true

sudo git config --system core.editor vim

sudo git config --system core.repositoryformatversion 0

sudo git config --system core.bare false

sudo git config --system core.logallrefupdates true

sudo git config --system core.precomposeunicode true

sudo git config --system push.default simple

sudo git config --system alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

sudo git config --system pull.rebase true

sudo git config credential.helper store // 记住密码

你可能感兴趣的:(git基本命令-配置)