1.在网页中自己的github账号下,创建仓库project
2.在本机创建文件夹project。
进入文件夹project.
(1) git init
(2) git add README.md
(3) git commit -m “first commit”
(4) git branch -M master
(5) git remote add origin https://github.com/账户名/库名.git
(6)git push – u origin master
其中遇到的问题:
第一次提交需要设置用户名和密码
git config –global user.name “用户名”
git config –global user.email “邮箱”
error
remote: Support for password authentication was removed on August 13, 2021
Create Personal Access Token on GitHub
From your GitHub account, go to
Settings
=>
Developer Settings
=>
Personal Access Token
=>
Generate New Token
(Give your password) =>
Fillup the form
=> click
Generate token
=>
Copy the generated Token
, it will be something like
ghp_XXXX
设置令牌,git push时在输入密码的地方输入token。可将token添加到远程仓库避免,每次提交都输入token.
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
error:
fatal: unable to access ‘https://github.com/**‘: TCP connection resset by peer
git config –global –unset http.proxy
git config –global –unset https.proxy
error:
git push.default的设置,如果设置为
git config –global push.default simple.
git push -u origin master,远程和本地分支名字一致才可以推送。
-u 作用可以直接用git push代替git push origin master,这里默认模式为simple不可以。
git push origin master成功。
用git push 提示git push –set-upstream origin master
git push –set-upstream origin master
提示fatal unable to access ‘https://github.com/XX’:TCP connection reset by peer
和failed connect to github.com:443:connection refused
git config –global –unset http.proxy
git config –global –unset https.proxy
git push origin master
依然有TCP connection reset by peer
ping github.com不通
我们打开
The Best IP Address, Email and Networking Tools – IPAddress.com
,查询如下两个域名,并分别记录下其对应的ip:
—-github.com
—-github.global.ssl.fastly.net
添加进/etc/hosts
nscd -i hosts
git push origin master依然有TCP connection reset by peer
git config http.postBuffer 524288000
push成功。
3.创建子系统
方法一:
网页上:建仓库,将远程仓库与本地仓库关联。
git init //初始化一个git 本地仓库
git submodule add <url> 路径 // <url> :指的是子仓库的远程地址 路径:子仓库.git相对于当前的路径
git add .
git commit -m “first commit ”
git remote add origin https://github.com/用户名/库名.git
如果远程有文件执行git pull orgin master
git commit -m “”
git push -u origin master
建子目录方法二:
在添加子模块的顶级目录 git submodule add <url> 路径
进入子目录文件夹进行操作
参考:
remote: Support for password authentication was removed on August 13, 2021_IT博客技术分享的博客-CSDN博客
使用Git clone 时下载速度太慢总是下载失败 – 简书
git push.default设置 – 失眠症 – 博客园
GitHub不再支持密码验证解决方案:SSH免密与Token登录配置 – 云+社区 – 腾讯云
子模块参考:
Git添加子模块(submodule)_杨林伟的博客-CSDN博客_git 添加子模块