GIT.md 1.7 KB


notion-id: 6f65b114-3851-4aa7-8e91-5ea5811100

Git常用命令


git remote set-url origin https://github.boki.moe/https://github.com/langgenius/dify.git
git remote -v
git pull origin main

远程配置【SSH】

C:\Users\zhensolid\.ssh
指定文件目录终端输入
ssh-keygen -t rsa -b 4096
打开*.pub文件复制内容到github其中的SSH配置
即可只用clone

git配置指令

git -V #查看版本

git config --global user.name "zhensolid"
git config --global user.email zhensolid@vip.qq.com
git config --global credential.helper store
git config --global --list


版本指令

#工作区
git init #初始仓库,可以指定仓库路径
git status #查看情况

#暂存区
git add 1.txt                        #将文件提交到暂存区
git rm --cached <file>...            # 将文件从暂存区取回

#版本库
git commit -m "update"              #将文件进行提交
git log                              #查看提交记录
git ls-file                          #查看版本库的文件

版本回退 ![[Notion/技术支持/GIT/attachments/Untitled.png]]

git reflog #查看回退记录
git reset  #回退版本
git reset --hard HEAD^  #退回上一个版本

版本比较

HEAD  #最新的提交ID
HEAD~2 #最新提交之前的第二个版本
git diff            #查看工作区VS暂存区
git diff HEAD       #查看工作区VS版本库 没有执行提交操作
git diff --cached   #暂存区VS版本库
git diff HEAD~ HEAD  #比较特定两个版本

文件忽略

.gitignore文件【忽略文件提交到版本控制】
例如
doc/*.txt

可在github下载gitignore模板