美文网首页
常见的git命令

常见的git命令

作者: 人世看客 | 来源:发表于2022-04-28 09:38 被阅读0次

    git创建分支

    • 在当前分支创建本地分支 git branch -b xxx
    • 在当前分支创建本地分支并跳转到新分支 git checkout -b xxx
    • 根据已有分支创建新的分支 git checkout -b 新分支名

    git 切换分支

    • 切换本地分支git checkout xxx

    git 删除分支

    • 删除本地分支 git branch -D xxx 不在当前删除分支,
    • 删除远程分支 git push origin --delete xxx

    git 将本地分支推到远程仓库

    • 本地分支推送到远程仓库git push origin xxx

    git 缓存命令

    • 缓存当前分支代码 git stash save '缓存名字'
    • 查看缓存git stash list
    • 恢复指定缓存并删除 git stash pop 缓存id
    • 查看stash删除历史记录 git fsck
    • 找回删除stash内容 git stash apply xxx(id)

    git 撤回命令相关

    • 撤回上一次commit提交 git reset HEAD~

    远程仓库相关

    • 查看远程仓库地址 git remote -v
    • 删除远程关联仓库git remote rm origin
    • 关联远程仓库 git remote add origin xxx远程地址

    git查看命令

    • 查看本地分支 git branch
    • 查看远程分支 git branch -r
    • 查看远程和本地所有分支 git branch -a
    • 查看远程仓库地址 git remote -v

    git用户相关

    • 查看当前用户名 git config user.name
    • 查看当前邮箱 git cofig user.email
    • 修改当前用户 git config --global user.name 'xxx用户名'
    • 修改当前邮箱 git config --global user.email 'xxx邮箱'

    tag命令相关

    • 新建本地tag: git tag -a 'xxx名称' -m 'xxx备注'
    • 推送本地tag: git push origin 'xxxTag'
    • 推送本地所有tag: git tag origin --tags
    • 删除本地tag: git tag -d tagName
    • 删除远程tag: git push origin :refs/tags/tagName

    git合并分支相关

    • 先切换到要合并的分支(开发分支r-1.2.3合并到dev, 就先切换到dev)git checkout dev
    • 然后合并git merge r-1.2.3(记得先pull一下,看是否远程有更新)
    • git status查看状态(是否有冲突)
    • git add 冲突文件

    相关文章

      网友评论

          本文标题:常见的git命令

          本文链接:https://www.haomeiwen.com/subject/gbiryrtx.html