赞
踩
.gitignore文件:忽略不需要上传的文件
.git:git init后自动生成的文件
.gitmodules:子储存库添加的文件
README.md:这个是说明文件,使用Markdown语法编写
仓库别名在前,分支名在后
本地仓库在前,远程仓库在后
push:从本地仓库到远程仓库(推出去)
pull:从远程仓库到本地仓库(拉回来)
当本地储存库中有其他已经克隆下来的储存库时,如果直接push推到远程仓库,远程仓库将无法访问嵌入的储存库。因此,需要在本地最外层储存库根目录中新建.gitmodules隐藏文件。内容格式如下:
[submodule “储存库子类别名”]
path = 储存库相对于外层储存库根目录的路径
url = git://github.com/××××/××××.git 储存库url
添加如上内容后重新执行
git add .
git commit -m ‘’
git push origin master
即可看到远程仓库中出现了该子储存库,并且链接指向url中的地址
注意:在修改该文件之后需要重新添加文件以及commit和push
git config --global http.proxy "localhost:1081"
git config --global https.proxy "localhost:1081"
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.fatal: The remote end hung up unexpectedlyfatal: early EOFfatal: index-pack failed
原因:git缓存区空间不足,数据溢出导致错误
解决办法:
git config --global http.sslVerify false
git config --global http.postBuffer 1048576000
git config --global https.sslVerify false
git config --global https.postBuffer 1048576000
输入以上四条命令后重新git clone即可,或在~/.gitconfig配置文件中修改
2. git push的时候报错
fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
出现这个问题是因为没有在github账号添加SSH key
解决方法:
1.在终端输入。
ssh-keygen -t rsa -C "username" (注:username为你git上的用户名)
如果执行成功。返回
Generating public/private rsa key pair.Enter file in which to save the key (/Users/username/.ssh/id_rsa):Generating public/private rsa key pair.Enter file in which to save the key (/Users/username/.ssh/id_rsa):
首先,说明一下,这里的username是你电脑上的用户名然后,在这里就是设置存储地址了.我们直接按回车,会出现一下两种情况的一种:
(1)如果正常运行的话,会出现
Enter passphrase (empty for no passphrase):
然后我们直接回车
(2)有的时候我们可能会出现
/Users/your username/.ssh/id_rsa already exists.Overwrite (y/n)?
这说明你已经设置了存储地址,我们输入“y”覆盖Overwrite (y/n)? y回车
上面的任意两种情况之后,会出现
Enter same passphrase again:
再次回车,这时候你会看见:
Your identification has been saved in /Users/username/.ssh/id_rsa.Your public key has been saved in /Users/username/.ssh/id_rsa.pub.The key fingerprint is:58:42:8b:58:ad:4b:b5:b9:6d:79:bf:8c:f9:e2:2b:ed usernameThe key's randomart image is:+--[ RSA 2048]----+| ... || o oo. || . .ooo. || o o+ || . ..oS. || . . + . || . o . || . o+. || +E++. |+-----------------+
这说明SSH key就已经生成了。文件目录就是:/Users/username/.ssh/id_rsa.pub.
我们执行cat命令查看文件的内容:
cat /User/username/.ssh/id_rsa.pub
这时候会看见:
ssh-rsa AAAAB3NzaC1yc2。。。。。。。。。后面的内容我省略了
(说明:ssh-rsa 后面的内容这就是你的SSH keys)
把显示出来的SSH keys直接添加到github账户设置里边的SSH keys
最后再执行git clone命令就可以了
在这里贴出我的.gitconfig配置文件(一共两个)
Socks5代理配置
[user] name = Phillweston email = 2436559745@qq.com [http] proxy = socks5://127.0.0.1:1080 sslVerify = false postBuffer = 1024m [core] packedGitLimit = 512m packedGitWindowSize = 512m [pack] deltaCacheSize = 2047m packSizeLimit = 2047m windowMemory = 2047m [https] proxy = socks5://127.0.0.1:1080 sslVerify = false postBuffer = 1024m
HTTP代理配置
[user] name = Phillweston email = 2436559745@qq.com [http] proxy = localhost:1081 sslVerify = false postBuffer = 1024m[core] packedGitLimit = 512m packedGitWindowSize = 512m [pack] deltaCacheSize = 2047m packSizeLimit = 2047m windowMemory = 2047m [https] proxy = localhost:1081 sslVerify = false postBuffer = 1024m
注:sslVerify和postBuffer要在http和https中写两遍gitconfig输入完命令后即可在.gitconfig隐藏文件中自动生成,不需要在.bashrc中写 github如果使用http方式克隆,在每一次push代码的时候都需要输入用户名和密码,
解决办法:使用ssh克隆(把http(s)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。