• git 实战基本操作


     一、git 基本命令操作操作

    1.初始化git
      git init
    2.添加文件至本地缓冲区
      git add .
    3.将添加的文件提交至本地
      git commit -m"第一次提交"
    4.添加git地址
      git remote add origin gitUrl地址
    5.将本地文件推送到线上git master分支
      git push origin maseter 
    6.拉取分支代码 
      git pull
    7.第一次从分支拉取代码
      git clone  gitUrl地址
    

      

    二、git分支切换  

    1、查看当前分支 
      git branch
    2、查看所有分支
      git branch -r
    3、切换分支
      git checkout 分支名称

    三、git版本回退

    a.强制回退 找不到回退版本后的内容
    1.查看版本号 找到需要回退的版本号
      git log
    2.本地回退到指定版本
      git reset --hard 版本号
    3.将本职版本推送到线上分支 需要强制推送
      git push -f
    b.回退版本,能找到回退后的内容
    1.查看版本号 找到需要回退的版本号
      git log

      2.使用“git revert -n 版本号”反做,并使用“git commit -m 版本名”提交:

        git revert -n  版本号

         git commit -m "提交注释"

      3.使用“git push”推上远程库

       git push

    四、git add 或commit后想撤销

    1.git add 后撤销
      git reset HEAD
    2.git commit 后撤销
      git reset --soft HEAD^

     

  • 相关阅读:
    软工第二次作业
    Internet: gmail on ubuntu
    English: assign
    Github: write blog by github
    Linux: left shift key not working on ubuntu18.04
    Using Doxygen to generate code documents
    Cpp: object lifetime
    Cpp: struct constructor
    Cpp: pass by reference
    HLS Stream Library
  • 原文地址:https://www.cnblogs.com/directiones/p/13534195.html
Copyright © 2020-2023  润新知