本地与Github连接:
从连接到上传
1.用户邮箱设置
注释性设置,不影响任何登录
git config --global user.name "userxxx"
git config --global user.email "yourname@email.com"
2.生成密钥
ssh-keygen -C 'your@email.address' -t rsa
3.复制密钥到剪贴板
clip < ~/.ssh/id_rsa.pub
将该密钥复制到Github中生成新的密钥
如果后续改变了密钥则需要重新init仓库,否则会出现报错\302\226git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.
4.验证连接
ssh -T git@github.com
上传内容:
1.初始化本地仓库
设置选定路径
Yue@LAPTOP-REAIP07E MINGW64 ~
$ cd
Yue@LAPTOP-REAIP07E MINGW64 ~
$ cd D:
Yue@LAPTOP-REAIP07E MINGW64 /d
$ cd GitRes
Yue@LAPTOP-REAIP07E MINGW64 /d/GitRes
$ cd CodeLS
Yue@LAPTOP-REAIP07E MINGW64 /d/GitRes/CodeLS
$ pwd
/d/GitRes/CodeLS
初始化仓库,创建.git文件
Yue@LAPTOP-REAIP07E MINGW64 /d/GitRes/CodeLS
$ git init
Initialized empty Git repository in D:/GitRes/CodeLS/.git/
配置github地址
$ git remote add origin https://github.com/calendaryue/survey_for_DP.git
2.上传文件
将文件放到本地仓库中,全部上传
$ git add .
检查状态
$ git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: summary/summ.xlsx
添加上传注释
$ git commit -m "lastime"
[master (root-commit) 044fcbb] lastime
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 summary/summ.xlsx
$ git commit -m "laslastime"
[master 1f1f055] laslastime
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
上传到github
git push -u origin master
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 10.52 KiB | 10.52 MiB/s, done.
Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/calendaryue/survey_for_DP.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
错误解决error: src refspec main does not match any error: failed to push some refs to 'https://github.com/calendaryue/survey_for_DP.git'
1.分支不存在,建立master分支
git checkout -b master
2.没有使用git add和git commit将文件添加至缓存,添加备注
git add .
git commit -m "xxx"
3.没有README文件
touch README