git 常用命令

git clone

  • 显示所有分支
    git branch -a

  • 添加标签(tag)
    git tag -a xxx

  • 删除本地标签
    git tag -d xxx

  • 上传标签至远程仓库
    git push origin xxx

  • 从远程仓库删除标签
    git push origin :refs/tags/xxx

  • 获取当前分支push远程仓库地址
    git remote -v|grep push|awk '{print $2}'

  • 获取当前分支源远程仓库地址
    git remote -v|grep fetch|awk '{print $2}'

  • 从当前分支创建新分支
    git checkout -b xxx
    git push origin xxx

  • 回退至某个版本
    git log查看待回退版本的commit id
    git reset --hard [commit id]

  • 提交时忽略文件权限变化
    git config core.filemode false // 当前版本库
    git config --global core.fileMode false // 所有版本库
    cat .git/config // 查看git的配置文件

  • clone指定日期后的记录
    git clone ----shallow-since="2025-02-19T00:00:00+0800"

  • 修改最近一次提交的日志
    git commit --amend

  • 生成最近记录的patch
    git format-patch --subject-prefix='PATCH' -1

  • 提交记录时附带签名
    git commit -s

posted on 2018-04-20 09:17  zlyang  阅读(156)  评论(0)    收藏  举报

导航