GitHub使用总结

(1) 仓库 (Repository) 仓库是用来存放项目代码,每一项目对应一个仓库。

(2) 收藏 (Star) 收藏别人的仓库,方便自己查找。

(3) 复制/克隆项目 (Fork)。
别人仓库的代码可以克隆到自己的账号下的中,可以对仓库进行更改。自己在仓库中对bug进行更改不会影响原作者的仓库,但可以通过向原作者发起请求 (Pull Request)。Fork也可以理解为分叉。

(4) 关注(Watch)
使用Watch功能关注了其他作者的仓库,如果作者的仓库发生更新,会发送通知到自己的账户上(类似于关注了别人就可以关注别人的动态)。

(5) 事物卡片(Issue)
发现别人的仓库代码出现Bug或有疑问时,可以通过Issue来和代码的作者进行咨询和讨论。然后作者可以收到别人的提问,然后可以回复。回复完成可以关闭当前的Issue。

git的使用流程

什么是git?

Git(读音为/gɪt/)是一个开源的[分布式]版本控制系统,可以有效、高速地处理从很小到非常大的项目版本管理。

(1) 工作区(Working Directory) 添加、编辑、修改文件等操作。

(2) 暂存区(Stage) 暂存已修改的文件,最后会统一提交到Git仓库中。

(3) Git仓库(Git Repository) 最终确定的文件保存到Git仓库成为一个新版本。

Git工作流程

Git工作流程有:

(1) 在工作目录中添加、修改、删除文件;
(2) 将需要进行版本管理的文件放入暂存区
(3)将暂存区的文件提交到Git仓库中;

Git管理的文件三种状态对应Git工作流程:

(1) 已修改(modified)
(2) 已暂存(staged)
(3) 已提交(committed)

常用命令

初始化仓库命令

git init

新建文件命令

touch README.md

添加到缓存区的命令、

git add README.md

添加到仓库的命令

git commit -m “提交README.md文件”

推到GitHub的命令

git branch -M main

git remote add origin https://github.com/FeiPF2020/chapter1.git

git push -u origin main //可以替换为SSH

下拉到本地的命令

git pull

git status

cat README.md

例程演示

小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ 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 directoryinit              Create an empty Git repository or reinitialize an existing onework on the current change (see also: git help everyday)add               Add file contents to the indexmv                Move or rename a file, a directory, or a symlinkrestore           Restore working tree filesrm                Remove files from the working tree and from the indexsparse-checkout   Initialize and modify the sparse-checkoutexamine the history and state (see also: git help revisions)bisect            Use binary search to find the commit that introduced a bugdiff              Show changes between commits, commit and working tree, etcgrep              Print lines matching a patternlog               Show commit logsshow              Show various types of objectsstatus            Show the working tree statusgrow, mark and tweak your common historybranch            List, create, or delete branchescommit            Record changes to the repositorymerge             Join two or more development histories togetherrebase            Reapply commits on top of another base tipreset             Reset current HEAD to the specified stateswitch            Switch branchestag               Create, list, delete or verify a tag object signed with GPGcollaborate (see also: git help workflows)fetch             Download objects and refs from another repositorypull              Fetch from and integrate with another repository or a local branchpush              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.小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ touch wpf.cpp小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git status
On branch center
Untracked files:(use "git add <file>..." to include in what will be committed)dwpf.cppnothing added to commit but untracked files present (use "git add" to track)小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ vim wpf.cpp小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ cat wpf.cpp
#include<iostream>
using namespace std;
int main(){int a = 1;int b = 2;cout<<a+b<<endl;return 0;
}小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git add wpf.cpp
warning: LF will be replaced by CRLF in wpf.cpp.
The file will have its original line endings in your working directory小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git status
On branch center
Changes to be committed:(use "git restore --staged <file>..." to unstage)new file:   wpf.cppUntracked files:(use "git add <file>..." to include in what will be committed)d小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git commit -m "提交wpf.cpp文件"
[center 28b3816] 提交wpf.cpp文件1 file changed, 8 insertions(+)create mode 100644 wpf.cpp小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git status
On branch center
Untracked files:(use "git add <file>..." to include in what will be committed)dnothing added to commit but untracked files present (use "git add" to track)小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git log
commit 28b38166b64c8f170c5610897ee121c23cfd58ff (HEAD -> center)
Author: FeiPF2020 <wpfn218925@163.com>
Date:   Sat May 14 17:11:28 2022 +0800提交wpf.cpp文件commit ad19af6d975f036e3f2a8547502977bc00ba4209
Author: FeiPF2020 <wpfn218925@163.com>
Date:   Sat May 14 17:01:59 2022 +0800‘提交文件’commit fa4626e4e03eee391e618321cf27d85ffa35095f (master)
Author: wpf <pfwangin2020@outlook.com>
Date:   Thu Sep 9 06:56:16 2021 +0800add style.csscommit 3b59a44ff6390ef905c23206c4b4fb97d7de1e8e
Author: wpf <pfwangin2020@outlook.com>
Date:   Wed Sep 8 01:41:01 2021 +0800add modified index.html add a head.commit 00a1703d0f807918dc056ac20fa6a386a029f6a2
Author: wpf <pfwangin2020@outlook.com>
Date:   Wed Sep 8 01:36:22 2021 +0800add index.html小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git log --pretty=oneline
28b38166b64c8f170c5610897ee121c23cfd58ff (HEAD -> center) 提交wpf.cpp文件
ad19af6d975f036e3f2a8547502977bc00ba4209 ‘提交文件’
fa4626e4e03eee391e618321cf27d85ffa35095f (master) add style.css
3b59a44ff6390ef905c23206c4b4fb97d7de1e8e add modified index.html add a head.
00a1703d0f807918dc056ac20fa6a386a029f6a2 add index.html小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git log --oneline
28b3816 (HEAD -> center) 提交wpf.cpp文件
ad19af6 ‘提交文件’
fa4626e (master) add style.css
3b59a44 add modified index.html add a head.
00a1703 add index.html小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ gitreflog
bash: gitreflog: command not found小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git reflog
28b3816 (HEAD -> center) HEAD@{0}: commit: 提交wpf.cpp文件
ad19af6 HEAD@{1}: commit: ‘提交文件’
fa4626e (master) HEAD@{2}: checkout: moving from master to center
fa4626e (master) HEAD@{3}: checkout: moving from 3b59a44ff6390ef905c23206c4b4fb97d7de1e8e to master
3b59a44 HEAD@{4}: checkout: moving from master to 3b59a44ff6390ef905c23206c4b4fb97d7de1e8e
fa4626e (master) HEAD@{5}: commit: add style.css
3b59a44 HEAD@{6}: commit: add modified index.html add a head.
00a1703 HEAD@{7}: commit (initial): add index.html小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (center)
$ git branch -M main小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (main)
$ git remote add origin https://github.com/FeiPF2020/chapter1.git小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (main)
$ git push -u origin main
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 16 threads
Compressing objects: 100% (13/13), done.
Writing objects: 100% (16/16), 1.72 KiB | 879.00 KiB/s, done.
Total 16 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/FeiPF2020/chapter1.git* [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (main)
$ git pull origin master
fatal: unable to access 'https://github.com/FeiPF2020/chapter1.git/': OpenSSL SSL_read: Connection was reset, errno 10054小城独困@LAPTOP-KDFLLFJE MINGW64 /g/git使用 (main)
$ git pull
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 651 bytes | 130.00 KiB/s, done.
From https://github.com/FeiPF2020/chapter128b3816..2fb70fb  main       -> origin/main
Updating 28b3816..2fb70fb
Fast-forwardhh.c | 2 ++1 file changed, 2 insertions(+)create mode 100644 hh.c

【git及GitHub使用总结】(一)相关推荐

  1. Git与github基本操作

    一.  git安装与简单配置 1.      git的安装 首先进入git的官方网站git-scm.com 下载自己电脑对应的git版本,然后点击安装即可 点击上图的红色部分进行下载 安装的时候直接默 ...

  2. 用 Git 和 Github 提高效率的 10 个技巧!

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试资料 来源:segmentfault.com/a/11900000038 ...

  3. 在Pycharm工具中配置集成Git和GitHub

    在Pycharm工具中配置集成Git和GitHub 1.集成Git. 打开Pycharm,  点击File-->Settins-->Version Control-->Git 然后在 ...

  4. R,Git和Github(下)

    作者:Wenhu 博客:http://bioinfostar.com/ 本讲第一部分,介绍git的"足够你用"命令:本讲为第二部分,介绍github的主要用途,包括版本管理.分枝管 ...

  5. clone git 修改保存路径_Git和Github详细入门教程(别再跟我说你不会Git和Github)

    前言:成功不是将来才有的,而是从决定去做的那一刻起,持续累积而成.你好,我是梦阳辰,快和我一起搞定Git和Github吧. 文章目录 01.Git概述 02.Git的本地仓库操作 Git的版本回退操作 ...

  6. 关于Git和Github你不知道的十件事

    Git 和 GitHub都是非常强大的工具.即使你已经使用他们很长时间,你也很有可能不知道每个细节.我整理了Git和GitHub可能提高日常效率的10个常用技巧. GitHub 快捷键: t 和 w ...

  7. Windows 下使用Git管理Github项目

    Git Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理.最初由Linus Torvalds编写,用作Linux内核代码的管理.在推出后,Git在其它项目中也取得 ...

  8. 用Git向gitHub上传项目

    用Git向gitHub上传项目 1.安装git 2.在git安装目录下,运行git-bash.exe  如图所示 3.在git中绑定你注册gitHub是的用户名.邮箱. $ git config -- ...

  9. git和github的关系

    写在前面:我身边好多人问我git和github的区别,想必对于好多人没学过的大佬们恐怕也是一脸懵逼,但是不知道也是不行的,所以我今天就来讲一讲这二者的区别和联系. 用一句话形容这二者的关系:git是弓 ...

  10. git push github SSL报错处理

    本文仅供学习交流使用,如侵立删!demo下载见文末 git push github SSL报错 问题:OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connect ...

最新文章

  1. 2018-3-10论文(网络评论非结构化信息表示与应用研究)笔记-----基于证据理论的综合评价模型建立
  2. 2021年人工神经网络第四次作业要求:第七题
  3. 10大主流压力测试工具推荐(转载)
  4. ES分组聚合:计算每个tag下的商品数量且某个filed包含指定关键字,分组,平均,每个tags下的平均价格,排序,指定范围区间
  5. 用C++设计一个不能被继承的类
  6. APICloud方法
  7. FLIP-24+-+SQL+Client
  8. mysql门派年龄最大的人_MySQL高级 第12章练习
  9. PowerDesigner导出SQL脚本运行注释出现乱码问题
  10. Python中使用tarfile压缩、解压tar归档文件
  11. go语言之进阶篇面向对象编程
  12. css怎么去掉字体样式,css怎么去掉字体粗体样式
  13. Microsoft Windows XP Embedded 技术常见问题
  14. Lumerical官方案例、FDTD时域有限差分法仿真学习(八)——光纤布拉格光栅(Fiber Bragg gratings)
  15. 手机端 js禁止页面滚动
  16. ncode毛刺探测glyph自动识别及清除毛刺 流程图
  17. ANSYS工程结构数值分析
  18. PMP中各种图形解释和使用场景
  19. 《自然》杂志:面对“电车难题”,不同国家的人有不同的道德选择
  20. 高数-导数的应用--函数凹凸性与拐点

热门文章

  1. 【转】常见英语单词前缀
  2. 评测|HPE Nimble AF全闪存系列,诠释真正的高端存储
  3. 科罗拉多大学波尔得分校计算机科学,科罗拉多大学波尔得分校院系设置
  4. html5期末大作业课程设计仿苹果官网(源码+报告)
  5. matlab打靶法求解薛定谔方程,用MATLAB语言解氢原子与类氢离子的定态薛定谔方程...
  6. 干货分享|Research Essay写作的规范及步骤详解
  7. 在我的订单中,点击去付款查看每个订单详情
  8. 启程Objectvie-C(绿柠檬学习笔记)
  9. git报错以及解决方法
  10. 【面试笔试-c/c++】人民搜索2012校园招聘试题