GithubHelp home page GithubHelp logo

git-it's Introduction

git学习文档!

git learn 文件夹记录了git的完整学习过程:包括简单的操作指令、简单的操作过程、简单的示例、以及可能出现的问题。 ==以下是这次学习的主要参考资料== 参考视频

1 git基础(本地操作)

1.1 git仓库的创建步骤

  • 进入要管理的文件夹
  • 执行初始化命令:

    git init

  • 管理目录下的文件状态

    git status 注: 新增的文件和修改过的文件都是红色

  • 管理指定文件(红色变为绿色)

    git add 文件名 git add .

  • 生成版本

    git commit -m "版本描述"

1.2 git注意

  • 在第一次运行git的时候需要配置个人信息

    通过git config --global user.email "your [email protected]"配置默认邮箱 通过git config --global user.name "your name"配置默认名称

1.3 git三大区域

  • 工作区

    本地正在操作的文件夹,包括两部分

    • 新增文件/修改过的文件(使用git status指令后 红色的文件)。
    • 其他已经在仓库中的文件。
  • 暂存区

    将工作区通过git add 文件名 添加的文件

    • 使用git status指令后 绿色的文件
  • 版本库

    将暂存区通过git commit -m 提交的文件

1.4 git的回滚操作

  • git reset --hard 版本号
  • git reflog

1.5 git常用命令

流程图

  • git init: 初始化,让git管理当前文件夹。
  • git add 文件名:将文件添加到仓库的下一个版本变化中
  • git status : 检测当前仓库中的文件状态
  • git commit -m "描述信息" : 生成一个版本
  • git log
  • git checkout:将工作区中的所有改动回退。
  • git reset --mix/hard/soft
  • git reset HEAD 文件名:从暂存区回退。

2. git分支

  • 分支-主干(master)是一组相对的概念。
  • 在短期内无法完成开发任务,又不能影响主干上的迭代时,使用分支进行开发可以避免冲突。

2.1 最常使用git分支的方法

  • 创建分支dev来进行新功能的开发。
  • 创建分支tmpMaster来维护在进行新功能开发过程中,主干上出现的问题。
  • 维护完成后tmpMaster回归master。
  • dev开发完成后回归master。

2.2 git分支常用的指令

  • 查看分支

    git branch

  • 创建分支

    git branch 分支名称

  • 删除分支

    git branch -d 分支名称 // 需要合并 git branch -D 分支名称 // 不需要合并,直接删除

  • 切换分支

    git checkout 分支名称

  • 分支合并

    git merge 要合并的分支 注意:需要先切换到主干分支,并解决可能产生的冲突。

2.3 需要注意

  • 保持良好的习惯,创建dev分支来进行所有的开发。master需要时刻保持可正常运行的情况。

git-it's People

Watchers

田哲元 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.