推送代码到github

1,下载git到一个没有中文,没有空格的目录下
2,


image.png

这是安装程序的目录名称 不用改


image.png

使用什么编辑器 建议使用vim
image.png

配置本地库信息
gif config 前面这些步骤暂时没有时间写 后面补充


git生成密钥

ssh-keygen -t rsa -C "你的gitbub账号注册的邮箱"
//比如我是1770@qq.com
然后出现下面这些信息,一直按回车就是。 代码演示↓
PS E:\1xxxn\ve\veriface> ssh-keygen -t rsa -C "1770@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Administrator/.ssh/id_rsa):
C:\Users\Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Administrator/.ssh/id_rsa.
Your public key has been saved in C:\Users\Administrator/.ssh/id_rsa.pub. //你的ssh key就在这个地址里
The key fingerprint is:
SHA256:TcOZ9IlKBdGITccm6cDNklVrdg38BkdH+LxxrkInXuM 1770@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| . O=O=....oo|
| * B=+o+o. |
| +.o@ ++.o |
| ..
o o.+|
| S . . .+|
| o +..|
| o = o |
| o E |
| . |
+----[SHA256]-----+

现在就是你的密钥生成成功了,这样查看↓

cat C:\Users\Administrator/.ssh/id_rsa.
//注意Administrator是你当前电脑的用户名 每个人都有可能不一样 你可以在上面我标注的地方找到
生成成功会出现一个 ssh ·······AAAAAA······的一串代码 全部复制下来,粘贴到github的settings-->ssh key中

这样检查你的密钥与本地密钥是否一致

运行 ssh -T git@github.com

PS E:\1lanyan\veriface修改样式版\veriface>
Hi Judy33! You've successfully authenticated, but GitHub does not provide shell access.
出现这句话就是添加密钥成功了 ↑

现在提交代码↓

PS E:\1lanyan\veriface修改样式版\veriface> git push origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

出现↑这种错误说明没有关联本地库和远程库

这样验证↓

运行 git remote –v

error: Unknown subcommand: –v
usage: git remote [-v | --verbose]
or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
or: git remote rename <old> <new>
or: git remote remove <name>
or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
or: git remote [-v | --verbose] show [-n] <name>
or: git remote prune [-n | --dry-run] <name>
or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
or: git remote set-branches [--add] <name> <branch>...
or: git remote get-url [--push] [--all] <name>
or: git remote set-url [--push] <name> <newurl> [<oldurl>]
or: git remote set-url --add <name> <newurl>
or: git remote set-url --delete <name> <url>
-v, --verbose be verbose; must be placed before a subcommand

可以看到报错了↑

这样关联本地库和远程库↓

git remote add origin ssh://git@github.com/Judy33/veriface.git //@后面的部分可以在git clone的地址中找到

image.png

再次git remote -v检查↓

PS E:\1lanyan\veriface修改样式版\veriface> git remote -v
origin ssh://git@github.com/Judy33/veriface.git (fetch)
origin ssh://git@github.com/Judy33/veriface.git (push)

可以看到关联了↑

上传代码再次报错↓

PS E:\1lanyan\veriface修改样式版\veriface> git push origin master
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.
Connection reset by 13.229.188.59 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这是要你把13.229.188.59添加到path里,打开C:\Windows\System32\drivers\etc\hosts 在里面添加 13.229.188.59 github.com这句话

报错就消失了

再次提交依然报错 以为我的github上已经有了一个readme文件 我的本地与远程不一致 需要git pull --rebase origin master一下 ↓

PS E:\1lanyan\veriface修改样式版\veriface> git push origin master
To ssh://github.com/Judy33/veriface.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'ssh://git@github.com/Judy33/veriface.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
PS E:\1lanyan\veriface修改样式版\veriface> git pull --rebase origin master
warning: no common commits
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 1.20 KiB | 7.00 KiB/s, done.
From ssh://github.com/Judy33/veriface

  • branch master -> FETCH_HEAD
  • [new branch] master -> origin/master
    warning: unable to rmdir 'veriface': Directory not empty
    First, rewinding head to replay your work on top of it...
    Applying: init
    Applying: veriface base on BaiDuAI wrriten by vue
    Applying: frist commit
    Applying: frist commit

现在就可以正常提交了

一次正常的代码更新 查看状态 提交的流程

image.png

git push origin master时出现↓这种错误可能是网不好 重新提交一次就可以了 也有可能是文件太大了 重新提交一次试试

image.png

$ git rm -r --cached target github上无法删除具体文件 用这个命令行执行 target为文件名

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。