目录
- 一. GitHub ssh-key配置
- 二. 添加GitHub仓库
- Git提交本地代码到Github仓库
- 远程克隆仓库到本地的文件夹再上传
- 本地的无.git的文件夹上传到远程仓库
- 三. Git删除Github仓库或某个文件或文件夹
- 1.删除已有Github仓库
- 2.删除Github中的某个文件或文件夹
- ①如果没有建立本地库或者克隆远程库,需
- ②如果已经有建立本地库或者克隆远程库,需
- 删除总流程
- 四. Git 错误记录
仅供本人记录查阅
全网最丝滑的 本地仓库上传GitHub操作 (Git建立本地仓库并上传代码到GitHub中)-------摆脱繁琐和冗余 清晰明了!!
全网最丝滑的 Git克隆远程仓库操作 (Git克隆远程仓库并上传代码到远程仓库中)-------摆脱繁琐和冗余 清晰明了!!
Git 删除 GitHub仓库的文件——详细操作
一. GitHub ssh-key配置
- 验证
ssh -T git.com
- 配置用户名和邮箱
git config --global user.name "EliasJie"
git config --global user.email "meiyouyudi@qq.com"
- 生成ssh-key
ssh-keygen -t rsa -C "meiyouyudi@qq.com"
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
$
二. 添加GitHub仓库
Git提交本地代码到Github仓库
远程克隆仓库到本地的文件夹再上传
本人以前写的
四. 克隆远程仓库 (核心操作)
现在写的
- 显示当前Github仓库的状态
git status
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)
- 输入
git add .
git add .
- 输入
git commit -m 'first commits'
第一次会让输入git的邮箱、用户名,输入一下
git commit -m 'First commits'
- 输入
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
问题:如出现 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.
解决:先git pull
,后git push
git pull
git push
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>
- 文件夹的删除和文件不一样,需要多一个参数,如下
删除本地仓库文件夹 git rm -r,filename是你要删除的文件夹名字
git rm -r <filename>
我们要删除GitHub的Project2此文件夹
- 将本地内容推送到远程仓库 git push
git commit -m "XXXX"
- 把删除的文件恢复到最新版本 git checkout
git checkout
- 将本地内容推送到远程仓库 git push
git push
删除总流程
刷新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
我这里出现错误
fatal: unable to access ‘https://github.com/Noroom569/text.git/’: OpenSSL SSL_read: Connection was reset, errno 10054
git config --global http.sslVerify "false"
以后有问题继续扩充: