Git常用命令与常识

来源:互联网 发布:哈登数据库 编辑:程序博客网 时间:2024/05/22 13:50

Git SSH key 生成

git config --global user.name "xxx"git config --global user.email "xxxx@126.com"ssh-keygen -t rsa -C "xxxx@126.com"

生成key之后,将

mkdir testcd testgit initgit remote add origin git@xxxxx.gitgit pulldu -hgit merge origin/master

常见问题1:use something like the following in your configuration file

如果提示如下信息

If you often merge with the same branch, you may want touse something like the following in your configuration file:    [branch "master"]    remote = <nickname>    merge = <remote-ref>    [remote "<nickname>"]    url = <url>    fetch = <refspec>See git-config(1) for details.

则可以进行如下设置

vim .git/config 

设置的内容为:

[branch "master"]        remote = origin        merge = refs/heads/master

常见问题2:SSH - GitLab: Deploy keys are not allowed to push code. fatal: Could not read from remote repository

Gitlab中有两种key,
* deploy key:只读。只能pull,不能push代码到服务器端。Project=>Deploy Keys,在需要部署的某个project的setting中
* SSH key:可读可写。如果需要Push, 应该添加SSH key。Profile setting=> SSH Keys

常见问题3:error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large

原因是.git/config配置的文件传输方式是http方式,换成ssh方式进行文件传输即可

[remote "origin"]        url = https://xxxx.xx.git

改成

[remote "origin"]        url =  git@git://xxxx.xx.git

持续更新…

原创粉丝点击