git使用日常问题记录【按日期频繁记录,欢迎收藏】
创始人
2024-05-12 03:56:51
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.

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
修复 爱普生 EPSON L4... L4151 L4153 L4156 L4158 L4163 L4165 L4166 L4168 L4...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...