# 拉取指定分支的更新,再与本地的指定分支合并。
git pull origin xxxx
# 切换分支
git checkout v1.2.1_qc
# 创建分支并推送
git branch branch_name
git checkout branch_name
git push origin branch_name
# 克隆某个分支
git clone -b v2.8.1 https://xxx.git
# 指定本地文件夹名称
git clone git@github.com:whatever folder-name
# 带用户名
git clone https://username:pwd@git.code.tencent.com/xxx/xxx.git
# submodule
git submodule update
git submodule update --recursive —init
# 清除所有修改
git clean -d -f
# 放入缓存
git stash
git stash save “1.2.1test”
# 取出缓存
git stash pop
# 回退到当前提交(更改也没了)
cd projectPath
git checkout .
git checkout filename
git reset
# 回退到指定提交
git resete --hard
git resete --hard head^ 上一版本
git reset --hard 24b3404764050617de9496c8db49bf4a6d95707f
git reset --hard HEAD 表示回退到当前版本
# 本地原来的git clone地址更换成新建仓库的clone 地址
git remote -v //查看git对应的远程仓库地址
git remote rm origin //删除关联对应的远程仓库地址
git remote -v //查看是否删除成功,如果没有任何返回结果,表示OK
git remote add origin https://github.com/***.git //重新关联git远程仓库地址
# 更新当前文件夹:
cd projectFolder
git fetch
git checkout origin/master ./
# 更新当前文件夹下某文件:
cd projectFolder
git fetch
git checkout origin/master ./index.php
# 查看变化
git diff
# 修改上一次提交的commit注释:
git commit —amend #最上面一行就是上次提交的注释,编辑保存 比如:docs --story=tapdId.(https://www.tapd.cn/11111/prong/stories/view/11111117)
# 初始化当前目录,即创建Git仓库
git init
# 查看状态
git status
# 查看提交历史/日志
git log
git log --stat # 仅显示摘要选项
git log --pretty=oneline # 定制记录格式
git log --graph # 图像化分支和版本更新
# 提交变更
git add .
git commit -m 'xxxxx'
git push
# 查看当前版本库地址
git remote -v
# 查看当前分支
git branch
# 查看所有分支
git branch -a
# 删除远程分支
git branch -a 查看
git branch -r -d origin/branch-name 删除本地分之
git push origin :branch-name 推送到远程分支删除
# 删除本地分之:
git branch -d branch-name 删除本地仓库
# 显示当前库中的标签
git tag
# 添加标签
git tag -a v0.1 -m "my version 0.1"
常用git命令
于 2022-12-20 16:01:38 首次发布