Git及Github使用

使用角度

找开源项目的途径

• Trending:https://github.com/trending/

• HelloGitHub:https://github.com/521xueweihan/HelloGitHub

• 科技爱好者周刊:https://github.com/ruanyf/weekly

特殊的查找资源小技巧-常用前缀后缀

• 找百科大全 awesome xxx

• 找例子 xxx sample

• 找空项目架子 xxx starter / xxx boilerplate

• 找教程 xxx tutorial

Git 是什么

Git 的三个概念:提交 commit、仓库 repository、分支 branch

Git 常用命令

  1. git init :git 初始化
  • 没提交之前,文件夹为工作区,目前仓库里还是空着的
  1. git add <file> :将工作区的文件放入暂存区,git add . / git add -A 表示把所有文件都放入暂存区
  2. git commit -m "注释" :将暂存区的文件提交到仓库

需要首先配置好邮箱和名字:
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

  1. git log --stat :查看历史提交信息,打印出以下信息(也可以直接在 VScode 源代码管理的 COMMITS 中查看提交记录以及代码)
commit 55d884835498b2457750148c4f77afbc25e84f0e (HEAD -> master)  // 每一个commit会有一个hash值  
Author: xxx
Date:   xxx

    init      // 这个是提交的信息                          

 1k.bin                    | Bin 0 -> 1024 bytes
 Makefile                  |  25 ++
 imx6ull.lds               |  20 ++
 led.bin                   | Bin 0 -> 410 bytes
 led.c                     |  94 ++++++++
 led.dis                   | 597 ++++++++++++++++++++++++++++++++++++++++++++++
 led.elf                   | Bin 0 -> 68948 bytes
 led.h                     |  32 +++
 led.img                   | Bin 0 -> 8192 bytes
 led.imx                   | Bin 0 -> 7168 bytes
 led.o                     | Bin 0 -> 3160 bytes
  1. git checkout <file> :将未提交的代码放弃更改;git reset HEAD^ : 将已经提交的代码放弃更改,^ 指向上一次提交的

分支

  1. 创建分支:git checkout -b <branch_name>,注意是以当前分支为基础新建分支,最好是以 master 为基础创建分支
  2. 进入某分支:git checkout <branch_name>
  3. 查看当前分支:git branch
  4. 合并分支:git merge <branch_name> ,将别的分支所做的事情合并到本分支上
  5. 删除分支:git branch -D <branch_name>
posted @ 2024-04-15 11:27  jll133688  阅读(9)  评论(0编辑  收藏  举报