美文网首页
git工作常用命令

git工作常用命令

作者: 晚歌歌 | 来源:发表于2021-11-22 14:39 被阅读0次

    简介

    当我们使用IDEA作为开发工具时,基本上很多常用的git操作都有可视化按钮界面,下面罗列一下我工作中常用的命令以及不同命令或者同命令不同参数间的一些区别

    工作区、暂存区和版本库概念

    image.png
    image.png

    配置git个人信息

    git config --global user.name "Your Name"
    git config --global user.email "email@example.com"

    克隆代码

    git clone url


    image.png

    添加代码

    git add

    IDEA可配置自动add文件


    image.png

    删除工作区代码

    git clean

    提交代码

    git commit
    git commit --amend 追加提交


    image.png
    image.png

    推送代码

    git push origin (branchname)


    image.png

    拉取代码

    git pull 其实就是 git fetch 和 git merge FETCH_HEAD 的简写


    image.png

    分支管理

    git branch
    git branch (branchname)
    git checkout (branchname)
    git rebase 用法较复杂,自行查询


    image.png
    image.png

    暂存代码

    git stash (remark)
    git stash apply (remark)
    git pop

    image.png

    回滚本地代码

    image.png

    回滚代码库代码

    git revert

    git reset 可带如下三种参数:
    --soft 回滚版本,但保留这两个版本间的修改内容至工作区
    --mixed 默认,回滚版本,但保留这两个版本间的修改内容至暂存区
    --hard 回滚版本,且抛弃这两个版本间的修改内容

    相关文章

      网友评论

          本文标题:git工作常用命令

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