【Git】【Github】学习笔记

视频教程

【参考:【Github Desktop】图形化方式操作Git,大大降低Git操作门槛_哔哩哔哩_bilibili-【云影同学yunyuv】

【参考:git 详解,10分钟学会_哔哩哔哩_bilibili-【停止重构】

学习

码云教程:https://gitee.com/help/articles/4114

报错百度解决

快速查阅
【参考:git使用教程_代码写注释的博客-CSDN博客
【参考:git常用命令大全_create13的博客-CSDN博客

【参考:史上最全Git命令学习:从基础出发,上手原来如此So easy! - 知乎 非常全面

参考:Git 分支原来这么简单!边玩边学更轻松 – Gitee 官方博客
https://oschina.gitee.io/learn-git-branching/?demo

猴子都能懂得git入门

新建仓库最好不要选择默认的Readme.md文件,要不然后面提交会比较麻烦,要修改配置。
在这里插入图片描述

本地删除文件后也要git add *提交到本地仓库然后再push到远程仓库

git init 初始化

提交修改后的文件到远程仓库

git add 文件名 --添加文件
(git add .) 全部添加

git commit -m '提示' --提交文件到暂存区

git push origin xxx --推送到远程仓库

PS:xxx表示远程仓库的分支名,如果在第一次连接远程仓库时将本地与远程仓库的分支关联,后续提交时候可以直接输入 git push origin master或者git push

其他常用的命令

git status 查看本地仓库的文件状态(修改、删除、添加等等)

git branch -a --查看当前主干下有哪些分支

git checkout -b 新分支名新建分支并自动切换到该分支
例如新分支login

checkout  检测、结账、查看
branch  分支

把其他分支的代码合并到主分支

1.其他分支的代码先提交到本地仓库
2.本地切换到主分支
3.本地主分支合并其他分支
4.提交到远程仓库

git checkout 分支名 --切换分支

git merge 分支名 --主分支合并其他分支

git diff --查看分支代码改动

git remote add origin git@github:xxx.git 关联远程仓库为origin

把本地其他分支的代码推送到远程仓库

1.本地切换到其他分支
2.提交到远程仓库(origin是远程仓库的别名)
git push -u origin 分支名

使用rebase合并
bugFix合并到master

1.新建并切换到bugFix分支
git checkout -b bugFix
2.bugFix分支提交一次

3.切换为master分支再提交一次

4.再次切换到bugFix分支,rebase到master上
git rebase master

回退

【参考:git hard_xiaozhiwise的博客-CSDN博客

git reset --hard HEAD^  # 退到上一个版本
git reset --hard 1094a    # "1094a"为最新那个版本号,版本号没必要写全,前几位就可以了,Git会自动去找

git help

>>> git help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

单人开发

【参考:Git 与 GitHub 单人开发最新最全玩法教程!_哔哩哔哩_bilibili
在这里插入图片描述
在这里插入图片描述

忽略指定文件

【参考:git提交忽略指定文件_奥特蛋_mm的博客-CSDN博客

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

网络加速

下载 Watt Toolkit (推荐)
【参考:瓦特工具箱(Steam++官网) - Watt Toolkit
选择v2.8.6版本比较快
Steam++_win_x64_v2.8.6.exe
【参考:SteamTools 发行版 - Gitee.com

或者 修改host

下载SwitchHosts
【参考:oldj/SwitchHosts: Switch hosts quickly!
1.开启host文件修改权限
【参考:加速你的 GitHub 访问速度,使用 SwitchHosts 工具,畅享极速代码浏览体验!(全网最详细踩坑教程) - 知乎
2. 添加host
【参考:ineo6/hosts: GitHub最新hosts。解决GitHub图片无法显示,加速GitHub网页浏览。
【参考:GitHub Hosts | hosts

加速下载

脚本:【参考:Github 增强 - 高速下载

  • 直接点击下载 zip 压缩包
  • Git Clone 加速:
git clone https://ghproxy.com/https://github.com/salesforce/BLIP.git

https://ghproxy.com/ + git链接

查看项目大小

【参考:查看github项目大小 - Borber - 博客园

后期可以写成一个js脚本

https://api.github.com/repos/

直接在浏览器地址栏输入

https://api.github.com/repos/organization/repository

其中organization替换为项目的所有者(组织),repository替换为项目的名称`

返回的页面是描述这个项目的JSON数据,其中的size指的就是项目的大小,单位为kB(千字节)

例如 torvalds/linux 的访问为 https://api.github.com/repos/torvalds/linux

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值