# git **Repository Path**: fly-sy/git ## Basic Information - **Project Name**: git - **Description**: git基本使用,日常记录... - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-11-01 - **Last Updated**: 2023-07-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # git 常用命令 ## 记住自己的用户名和密码 git config --global credential.helper store ## 配置提交代码的人的用户名和邮箱 git config --global user.name "fly" // 配置用户名 git config --global user.email "942093888@qq.com" // 配置邮箱 ## 初始化 git init ## 查看当前状态 git status ## 添加所有文件到本地仓库 git add . ## 提交所有文件到本地仓库 git commit -m "描述" ## 查看日志 git log ## 代码回退到上一次提交 git reset --hard HEAD^ ## 连接远程服务 git remote add origin [远程路径] ## 删除远程路径 git remote remove origin master ## 将文件提交到主分支 git push -u origin master ## 查看所有的分支 git branch -a ## 查看所有的远程分支 git branch -r ## 创建新分支 git branch gh-pages ## 切换到新分支 git checkout gh-pages ## 提交到新分支 git push -u origin gh-pages ## 把远程分支拉到本地 git fetch origin dev(dev 为远程仓库的分支名) ## 把某个分支上的内容都拉取到本地 git pull origin dev(远程分支名称) ## 如果有未提交的更改,是不能 git pull 的 1. 先执行 git stash 2. 再执行 git pull --rebase origin master 3. 最后再执行 git push -u origin master