# git基本操作-学习笔记 **Repository Path**: caozqwe/git-notes ## Basic Information - **Project Name**: git基本操作-学习笔记 - **Description**: 学习Git的笔记 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-10-25 - **Last Updated**: 2023-10-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: Git ## README # git笔记 #### 配置账号 ```python # 单仓库配置 # 路径. .git/config git config user.name CaoZhen 配置用户名 git config user.email 15697929069@163.com 配置邮箱 # 全局配置 # 路径 C:\Users\CaoZhen\.gitconfig git config --global user.name CaoZhen git config --global user.email 15697929069@163.com ``` #### 命令 ```python git -v 查看当前的版本 git init 初始化git仓库 git clone 克隆远程仓库(HTTPS) git clone https://gitee.com/caozqwe/git-notes.git 本地项目名[可选] git status 文件状态 git add [文件名称] git add *.txt 会将所有的以.txt 结尾的文件 添加到暂存区 git commit -m '提交到本地仓库的说明' git log 查看提交记录 git log --oneline 查看提交记录 # 文件误删除(恢复) 方法1: git restore 文件名 方法2:(会丢失提交记录) 先 git log --oneline 查看到需要恢复到的哪个 git reset --hard 69d9041[版本号] 方法3: git revert 当前版本号 # 创建分支(创建之前必须有一次提交操作) git branch 分支名 # 查看分支 git branch git branch -v # 切换分支 git checkout 分支名 # 创建分支并进入分支 git checkout -b 分支名 # 删除分支 git branch -d 分支名 git branch -D 分支名 # 合并分支 git merge 分支名称 # 如果存在冲突 需要手动修改文件 # 然后再次 git add . git commit -m '提交' # 增加标签 git log 可以查看版本号 git tag [版本号] git tag 查看标签 #删除标签 git tag -d 标签名 git remote add origin [HTTPS或者SSH] # 推送到服务器 git push origin # SSH推送教程 https://www.bilibili.com/video/BV1wm4y1z7Dg/?p=29&spm_id_from=pageDriver&vd_source=64e547a559d46d23f8c866e18cc9230e # 拉取数据的操作 git pull origin ```