git使用日常问题记录【按日期频繁记录,欢迎收藏】
创始人
2024-05-12 05:03:55
0

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别人的项目到自己仓库并进行贡献

  1. 将远程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

在这里插入图片描述

  1. 修改相关文件,并上传到远程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
  1. 将修改提交给主账号的原作者,原作者决定是否合并你的修改

请添加图片描述
请添加图片描述

  • 点击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

  1. local : git checkout my-branch-name

  2. switch to a breach that came from a remote repo

    • 远程仓库的所有分支 : git pull
    • 切换分支 : git checkout --track origin/my-branch-name
  3. 本地仓库does not exist在远端

    • 方法一: git push -u origin my-branch-name
    • 方法二: git push -u origin HEAD
  4. 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

  1. To delete a remote branch, run this command:
    git push origin --delete my-branch-name
  2. 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.

相关内容

热门资讯

喜欢穿一身黑的男生性格(喜欢穿... 今天百科达人给各位分享喜欢穿一身黑的男生性格的知识,其中也会对喜欢穿一身黑衣服的男人人好相处吗进行解...
发春是什么意思(思春和发春是什... 本篇文章极速百科给大家谈谈发春是什么意思,以及思春和发春是什么意思对应的知识点,希望对各位有所帮助,...
网络用语zl是什么意思(zl是... 今天给各位分享网络用语zl是什么意思的知识,其中也会对zl是啥意思是什么网络用语进行解释,如果能碰巧...
为什么酷狗音乐自己唱的歌不能下... 本篇文章极速百科小编给大家谈谈为什么酷狗音乐自己唱的歌不能下载到本地?,以及为什么酷狗下载的歌曲不是...
家里可以做假山养金鱼吗(假山能... 今天百科达人给各位分享家里可以做假山养金鱼吗的知识,其中也会对假山能放鱼缸里吗进行解释,如果能碰巧解...
华为下载未安装的文件去哪找(华... 今天百科达人给各位分享华为下载未安装的文件去哪找的知识,其中也会对华为下载未安装的文件去哪找到进行解...
四分五裂是什么生肖什么动物(四... 本篇文章极速百科小编给大家谈谈四分五裂是什么生肖什么动物,以及四分五裂打一生肖是什么对应的知识点,希...
怎么往应用助手里添加应用(应用... 今天百科达人给各位分享怎么往应用助手里添加应用的知识,其中也会对应用助手怎么添加微信进行解释,如果能...
客厅放八骏马摆件可以吗(家里摆... 今天给各位分享客厅放八骏马摆件可以吗的知识,其中也会对家里摆八骏马摆件好吗进行解释,如果能碰巧解决你...
苏州离哪个飞机场近(苏州离哪个... 本篇文章极速百科小编给大家谈谈苏州离哪个飞机场近,以及苏州离哪个飞机场近点对应的知识点,希望对各位有...