git系列文章
文章目录
- 2023.1.14 将gitee仓库转移到github遇到的问题
- 1-1 `add`到暂存区,`commit`到仓库之后,不想push了???
- 1-2 git push大文件失败解决
- 1-3 上传多余文件,如何从远端仓库中删除
- 2023.1.15
- 1-1 github fork别人的项目到自己仓库并进行贡献
- 1-2 git 查看所有远程分支以及同步命令
- 1-2-1 List
- 1-2-2 create
- 1-2-3 switch
- 1-2-4 merge
- 1-2-6 delete
2023.1.14 将gitee仓库转移到github遇到的问题
1-1 add
到暂存区,commit
到仓库之后,不想push了???
- 怎么取消呢?
git reset --soft HEAD^
- git commit之后,想撤销commit
1-2 git push大文件失败解决
- 单词不能超过100MB,快算了,这是个大软件了
- push大文件失败
Enumerating objects: 16248, done.
Counting objects: 100% (16248/16248), done.
Delta compression using up to 12 threads
Compressing objects: 100% (10573/10573), done.
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (16248/16248), 6.33 GiB | 10.84 MiB/s, done.
Total 16248 (delta 5237), reused 16245 (delta 5237), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date
1-3 上传多余文件,如何从远端仓库中删除
![在这里插入图片描述](https://img-blog.csdnimg.cn/ed5b2dfc6db546dd8f51e357a25667f9.png)
git rm --cached filename
git commit -m "delete remote file filename "
git push -u origin master(此处是当前分支的名字)
2023.1.15
1-1 github fork别人的项目到自己仓库并进行贡献
- 将远程fork的项目下载到本地电脑
# 在桌面创建test目录
mkdir /Users/wangsaichao/Desktop/test
# 切换到test目录
cd /Users/wangsaichao/Desktop/test
# 创建并初始化git库
git init
# 链接到远程git仓库 -t main 使用 main 分支
git remote add origin -t main https://github.com/hannah-bingo/js-challenges.git
# 将远程git库下载到本地
git pull origin main
- 修改相关文件,并上传到远程fork仓库
# 将目录下所有文件都增加到本地库中。
git add .
# 提交更改到本地仓库
git commit -am '提交注释'
# 将本地的master分支改为main分支, github为避免联想奴隶制。在持续的外界影响之下,默认分支由master改为main。
# 但是git工具默认init还是创建的master分支 所以要改成main分支。
git branch -M main
# 将本地修改推到github上
git push -u origin main
- 将修改提交给主账号的原作者,原作者决定是否合并你的修改
- 点击New pull request之后的界面上显示了修改后的文件与原作者库里的文件有哪些地方不同
- 然后点击Create pull request 即可跳转到最后一个页面,在最后一个页面上写上自已的提交注释,点击Create pull request即可。
- fork别人的项目并进行贡献,仓库所有者进行合并操作
1-2 git 查看所有远程分支以及同步命令
墙:
Git Branches: List, Create, Switch to, Merge, Push, & Delete
- 直接上英语哇,没几个单词不认识😂
1-2-1 List
NOTE: The current local branch will be marked with an asterisk (*).
-
To see local branches, run this command:
git branch
-
To see remote branches, run this command:
git branch -r
-
To see all local and remote branches, run this command:
git branch -a
1-2-2 create
git checkout -b my-branch-name
1-2-3 switch
-
local :
git checkout my-branch-name
-
switch to a breach that came from a remote repo
- 远程仓库的所有分支 :
git pull
- 切换分支 :
git checkout --track origin/my-branch-name
- 远程仓库的所有分支 :
-
本地仓库does not exist在远端
- 方法一:
git push -u origin my-branch-name
- 方法二:
git push -u origin HEAD
- 方法一:
-
If your local branch already exists on the remote
git push
1-2-4 merge
git checkout master
git merge my-branch-name
1-2-6 delete
- To delete a remote branch, run this command:
git push origin --delete my-branch-name
- To delete a local branch, run either of these commands:
git branch -d my-branch-name
git branch -D my-branch-name
NOTE: The -d option only deletes the branch if it has already been merged. The -D option is a shortcut for --delete --force, which deletes the branch irrespective of its merged status.