Skip to content

git

1、设置用户名、邮箱

shell
    git config --global user.name "xxx"
    git config --global user.email "xxx"

2、本地

指令含义
git init初始化
git status查看当前状态
git add添加到暂存区
git commit提交
git log日志
touch .gitignore忽略
git config --list查看本地 git 配置

3、分支

指令含义
git branch -a查看本地的和远程的所有分支
git branch main创建本地的 main 分支
git branch -d main删除本地的 main 分支
git checkout dev切换到本地的 dev 分支
git branch -b dev创建并切换本地的 dev 分支
git merge bug合并 bug 分支内容到当前分支
git push origin --delete main删除远程的 main 分支

4、远程

指令含义
git clone克隆
git remote -v查看远程
git push提交远程
git fetch拉取远程
git diff查看不同
git pull origin main将远程 main 分支拉到本地
git rebase main将当前分支合到 main 分支

5、暂存区

指令含义
git ls-files查看当前暂存区的文件