liugang 发布的文章

生成密钥对

ssh-keygen -t ed25519 -C "your_email@example.com"
#or
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f D:\ssh\github_id_rsa
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f D:\ssh\gitee_id_rsa

选项

  • -b:指定密钥长度;
  • -e:读取openssh的私钥或者公钥文件;
  • -C:添加注释;
  • -f:指定用来保存密钥的文件名;
  • -i:读取未加密的ssh-v2兼容的私钥/公钥文件,然后在标准输出设备上显示openssh兼容的私钥/公钥;
  • -l:显示公钥文件的指纹数据;
  • -N:提供一个新密语;
  • -P:提供(旧)密语;
  • -q:静默模式;
  • -t:指定要创建的密钥类型。

配置config文件

C:\Users\liugang\.ssh 文件夹添加config文件

Host github.com
    HostName github.com
    User your_email@example.com
    PreferredAuthentications publickey
    IdentityFile D:\ssh\github_id_rsa

Host gitee.com
    HostName gitee.com
    User your_email@example.com
    PreferredAuthentications publickey
    IdentityFile D:\ssh\gitee_id_rsa

用ssh进行git操作

第一次使用需要生成指纹

git

git基础使用

创建一个新仓库

echo "# git-init" >> README.md #创建文件
git init #初始化
git add README.md #添加到暂存区
git commit -m "first commit" #提交到本地仓库
git branch -M main    #切换到main分支
git remote add origin git@github.com:tsingliu449966/git-init.git #添加origin远程仓库地址
git push -u origin main #推送到远程仓库的main分支

推送已存在的仓库

git remote add origin git@github.com:tsingliu449966/git-init.git #添加origin远程仓库地址
git branch -M main #切换到main分支
git push -u origin main #推送到远程仓库的main分支

查看日志

#查看状态
git status
#查看日志
git log
#查看所有操作日志 包括reset、分支切换等
git reflog
#回退提交
git reset --hard 6619fad
#创建dev分支
git branch dev
#切换到dev分支
git checkout dev

用户

git config --global --list
git config user.name
git config user.email

git config --global user.name "yourname"
git config --global user.email "youremail@xx.com"

暂存工作区

git stash
git stash apply
git stash --help

检查文件不同

git diff

git flow

新建分支

#创建分支
git branch dev

#创建并切换分支
git checkout -b dev

解决冲突

#拉取代码
git pull origin dev

#手动提交
git fetch origin dev
git merge FETCH_HEAD

git fetch origin some-branch:dev

#推送本地feature分支到远程feature分支
git push origin feature:feature

git fetch origin feature:dev
git merge FETCH_HEAD

git pull origin feature

回退版本

git reset --hard HEAD@{1}
git reset --hard 44d4c4d
git reset --hard head^
git reset --hard head~1

合并分支

#切换到dev分支
git checkout dev
#合并feature到dev分支
git merge feature

#切换到master分支
git checkout master
#合并dev到master分支
git merge dev

标签

git tag v1.0.0
git push origin master --tags

git tag -d v1.0.0
git tag list

git tag v1.1.0
git push origin :refs/tags/v1.0.0 #删除远程tag
git push origin :feature #删除远程分支

git branch -D feature #删除本地分支
git checkout -- test.txt #丢弃工作区的改动

git add test1.txt,test2.txt
git reset HEAD test2.txt #撤回加入暂存区的文件

git reset --hard head #切换回上一次提交

git --version  #查看版本
git config user.name
git config user.email

git config --global user.name "yourname"
git config --global user.email "youremail@xx.com"

git init #初始化
git remote add origin https://codeup.aliyun.com/xxxx/git-new.git #设置远程仓库
git add . #添加到暂存区
git commit -m 描述 #提交到本地仓库
git push -u origin master #推送到远程仓库

git status #查看状态
git log #查看提交日志

git rm 3.html #删除文件
#手动重命名 需要 git add new.html;git rm old.html;
git mv home.html index.html #命令行重命名文件
git mv 2.html home #移动文件
git mv index.html home/home.html #移动并重命名

git log --pretty=oneline home/home.html
git show 84e9ce1f929099f1fa56b5c844a29ac81fe0f289 #查看某个提交
diff --git a/home/home.html b/home/home.html # 查看变化详情

git diff #比较不同

git checkout -- home/home.html #恢复未添加到暂存区的修改
git reset HEAD home/home.html #撤销add添加到暂存区

git reset --hard HEAD^ #回到上一个版本
git reset --hard HEAD^^ #回到上二个版本
git reset --hard eaed3b7b2a9a4eece359924937b3601f2b07c637 #回到指定版本

git checkout eaed3b7b2a9a4e -- home/version.html #恢复指定文件到指定版本

git push -u origin master # 推送到远程仓库

git tag v1.0 #给版本创建一个标签
git tag # 查看标签
git tag v0.5 c8b5f9cb12c30 #给指定版本打标签
git tag -d v0.5    #删除指定tag
git push -u origin v1.0 #将标签推送到远程仓库

git branch dev # 创建分支
git branch # 检查分支 *代表当前分支 按首字母排序
git checkout dev # 切换分支
git branch -d test # 删除分支 不能删除当前分支 不能删除有commit的分支
git checkout -b test # 创建并切换分支
git branch -D test # 强制删除 可以删除有commit的分支

#合并分支
git checkout master # 切换到主分支
git merge dev # 合并分支

git merge --abort # 忽略其他分支的内容,保留当前分支的内容
#也可以手动修改 输入注释 然后提交

git log --oneline # 查看简洁日志
git log --oneline --graph # 查看版本路线

git fetch # 拉取远程仓库分支
git branch -av
git push origin --delete summer # 删除远程分支


git merge origin/test # 不同人修改了不同的文件处理

git fetch # 拉取远程仓库分支
git branch -av # 查看分支
git checkout -b test remotes/origin/test # 创建并检出分支 并和远端仓库关联

// 类型别名
let sum: (x: number, y: number) => number
const result = sum(1, 2)

type PlusType = (x: number, y: number) => number
let sum2: PlusType
const result2 = sum2(2, 3)

// 联合类型
type StrOrNum = string | number
let result3: StrOrNum = '123'
result3 = 123
let union = 1  | 2 | 3 | 4
// 字面量
const str: 'name' = 'name'
const number: 1 = 1


type Directions = 'Up' | 'Down' | 'Left' | 'Right'
let toWhere: Directions = 'Right'
// 交叉类型
interface IName {
  name: string
}
type IPerson = IName & {age: number}
let person: IPerson = { name: 'my name', age: 123 }