当前位置:   article > 正文

Git操作GitHub全记录

Git操作GitHub全记录

仅供本人记录查阅

全网最丝滑的 本地仓库上传GitHub操作 (Git建立本地仓库并上传代码到GitHub中)-------摆脱繁琐和冗余 清晰明了!!

全网最丝滑的 Git克隆远程仓库操作 (Git克隆远程仓库并上传代码到远程仓库中)-------摆脱繁琐和冗余 清晰明了!!

Git 删除 GitHub仓库的文件——详细操作

一. GitHub ssh-key配置

  1. 验证
ssh -T git.com
  • 1
  1. 配置用户名和邮箱
git config --global user.name "EliasJie"
git config --global user.email "meiyouyudi@qq.com"
  • 1
  • 2
  1. 生成ssh-key
ssh-keygen -t rsa -C "meiyouyudi@qq.com"
  • 1

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

93254 MINGW64 ~/Desktop
$ ssh-keygen -t rsa -C "meiyouyudi@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/93254/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/93254/.ssh/id_rsa
Your public key has been saved in /c/Users/93254/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:7jECk2ix0lWMXzSEDFG4J8jzfBLBzmn5jDVNijzpDQk meiyouyudi.com
The key's randomart image is:
+---[RSA 3072]----+
|     o.. o*+.    |
|    ..E B  o.    |
|  . .o O X +     |
| . = .= ^ = .    |
|. = +  *S% .     |
| o   o .* =      |
|      . +o       |
|       o o       |
|        .        |
+----[SHA256]-----+

93254 MINGW64 ~/Desktop
$ ssh -T git.com
The authenticity of host 'github.com (20.405.243.196)' can't be established.
ED25519 key fingerprint is SHA456:+DiY3wvvVfduJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Hi EliasJie! You've successfully authenticated, but GitHub does not provide shell access.

93254 MINGW64 ~/Desktop
$

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

二. 添加GitHub仓库

在这里插入图片描述
在这里插入图片描述

Git提交本地代码到Github仓库

远程克隆仓库到本地的文件夹再上传

本人以前写的
四. 克隆远程仓库 (核心操作)
现在写的

在这里插入图片描述

  • 显示当前Github仓库的状态
git status
  • 1
93254@WIN11DC MINGW64 ~/Desktop/OpenMV_Software (main)
$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        OpenMV peripheral/
        Project/
        ei_object_detection.py
        labels.txt

nothing added to commit but untracked files present (use "git add" to track)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 输入git add .
git add .
  • 1
  • 输入 git commit -m 'first commits'第一次会让输入git的邮箱、用户名,输入一下
git commit -m 'First commits'
  • 1
  • 输入git push将本地仓库中的提交(commits)推送到远程仓库
93254@WIN11DC MINGW64 ~/Desktop/OpenMV_Software (main)
$ git push
Enumerating objects: 65, done.
Counting objects: 100% (65/65), done.
Delta compression using up to 20 threads
Compressing objects: 100% (54/54), done.
Writing objects: 100% (64/64), 130.36 KiB | 379.00 KiB/s, done.
Total 64 (delta 2), reused 2 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), done.
To github.com:EliasJie/OpenMV_Software.git
   3ebb816..004f36f  main -> main

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

问题:如出现 error: failed to push some refs to

To github.com:EliasJie/Share-library.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'github.com:EliasJie/Share-library.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在这里插入图片描述
解决:先git pull,后git push

git pull
  • 1
git push
  • 1

93254@WIN11DC MINGW64 ~/Desktop/Share-library (main) $ git pull
remote: Enumerating objects: 5, done. remote: Counting objects: 100%
(5/5), done. remote: Compressing objects: 100% (2/2), done. remote:
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking
objects: 100% (3/3), 978 bytes | 81.00 KiB/s, done. From
github.com:EliasJie/Share-library 9da07f1…e3e8276 main ->
origin/main Merge made by the ‘ort’ strategy. README.md | 4 ++± 1
file changed, 3 insertions(+), 1 deletion(-)

93254@WIN11DC MINGW64 ~/Desktop/Share-library (main) $ git push
Enumerating objects: 19, done. Counting objects: 100% (15/15), done.
Delta compression using up to 20 threads Compressing objects: 100%
(9/9), done. Writing objects: 100% (9/9), 451.71 KiB | 1.29 MiB/s,
done. Total 9 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:EliasJie/Share-library.git e3e8276…e5746f1 main -> main

本地的无.git的文件夹上传到远程仓库

本人以前写的

第五、七节上传文件代码到远程仓库(重点操作 详细步骤)

三. Git删除Github仓库或某个文件或文件夹

1.删除已有Github仓库

删除Github中没有用的仓库

进入到需要删除的仓库里面,找到“settings”即仓库设置,

然后,在仓库设置里拉到最底部,找到“Danger Zone”即危险区域,

点击“Delete this repository”这样就可以删除该仓库了。

在这里插入图片描述

2.删除Github中的某个文件或文件夹

我们知道,在Github上我们只能删除仓库,并不能删除文件或者文件夹,所以只能用命令来解决。

①如果没有建立本地库或者克隆远程库,需

  • 新建文件夹

  • git bash here
    在新建的文件夹里右键git bash here打开终端,并执行git init初始化仓库

  • git clone <你的地址>
    找到github上要删除的仓库地址,并复制,在终端里输入git clone <你的地址>

②如果已经有建立本地库或者克隆远程库,需

  • 要删除文件的库里右键git bash here打开终端

在这里插入图片描述

在这里插入图片描述

  • 假如要删除GitHub的Project2此文件夹

  • 在终端里输入dir查看此文件夹下的文件和目录(文件夹)

在这里插入图片描述

  • 删除本地仓库文件 git rm ,filename是你要删除的文件名字
git rm <filename>
  • 1
  • 文件夹的删除和文件不一样,需要多一个参数,如下
    删除本地仓库文件夹 git rm -r,filename是你要删除的文件夹名字
git rm -r <filename>
  • 1

我们要删除GitHub的Project2此文件夹

在这里插入图片描述

  • 将本地内容推送到远程仓库 git push
git commit -m "XXXX"
  • 1

在这里插入图片描述

  • 把删除的文件恢复到最新版本 git checkout
git checkout
  • 1
  • 将本地内容推送到远程仓库 git push
git push
  • 1

在这里插入图片描述

删除总流程

在这里插入图片描述

刷新github仓库 就看见选定删除的文件夹没有了!!!大功告成!

在这里插入图片描述

四. Git 错误记录

Another git process seems to be running in this repository, e.g.
an editor opened by ‘git commit’. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.解决

错误
error: remote origin already exists.

git remote -v
git remote rm origin
  • 1
  • 2

在这里插入图片描述

在这里插入图片描述

我这里出现错误
fatal: unable to access ‘https://github.com/Noroom569/text.git/’: OpenSSL SSL_read: Connection was reset, errno 10054
在这里插入图片描述

git config --global http.sslVerify "false"
  • 1

在这里插入图片描述

以后有问题继续扩充:

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/549159
推荐阅读
相关标签
  

闽ICP备14008679号