首页 > 技术文章 > git 常用命令

zl-yang 2018-04-20 09:17 原文

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的配置文件

推荐阅读