Git 常用命令
#初始化git仓库
git init
#查看git文件状态(查看文件是否被git追踪)
git status
#查看所有本地分支 前面带有*号的是当前分支
git branch
#查看所有远程分支
git branch -r
#查看所有本地和远程分支
git branch -a
#创建分支
git branch 分支名
#切换分支
git checkout 分支名、
#切换分支并且转换过去
git checkout -b 新分支名
#分支模糊查找
git branch | grep 分支名
#删除本地分支(D 强制)
git branch -D 分支名
#删除远程分支
git push origin --delete 分支名
#如果没有被追踪
git add <file>...
git add pom.xml
#撤销追踪
git rm --cached <file>
git rm --cached pom.xml
#全部进行追踪
git add .
#提交到本地仓库
git commit -m "提交的消息"
#查看是否配置远程仓库
git remote -v
#设置远程仓库地址
git remote add origin https://gitee.com/AngeGit/springboot_miaosha.git
#提交到远程仓库
git push -u origin master
#第一次使用仓库需要先pull再push 所以这个时候可以进行强制合并,用下边的方式就OK了。
//把远程仓库和本地同步,消除差异
git pull origin master --allow-unrelated-histories
#删除缓存区指定文件
git rm --cached readme.txt
#清空缓存区
rm .git/index
#克隆远程地址的项目
git clone https://gitee.com/AngeGit/springboot_miaosha.git
#重复上述步骤
#拉取远程仓库的代码
git pull
#提交代码
git add .
#提交到本地仓库
git commit -m "消息"
#查看是否有远程仓库
git remote -v
#提交到远程仓库
git push -u origin test
#修改远程仓库地址
git remote set-url origin 远程仓库地址
#切换分支
git branch
git checkout master
#合并
git merge test
git push -u origin master
链接: https://loveiu.top/20220622/git/index.html#%E5%88%9B%E5%BB%BA%E4%BB%93%E5%BA%93