Git 使用入门

未完待续...git

1、基本概念

2、经常使用命令

1. 经常使用命令速查表(英文)

clipboard.png

2. 经常使用命令速查表(中文)

clipboard.png

3、场景应用

一、配置Git帐号

优先级:工程级 > 用户级 > 系统级
  • 系统级配置spa

    • --system 包含系统上没有给用户及其它们仓库的通用配置
    • 位于 /etc/gitconfig
  • 用户级配置code

    • --global 只针对当前用户
    • 位于 ~/.gitconfig 或 ~/.config/git/config
  • 工程级配置ip

    • 只针对当前仓库
    • 位于当前仓库的 .git/config
  • 查看Git配置rem

    git config user.name
    git config user.email
  • 添加全局配置it

    # Git global setup
    git config --global user.name "example"
    git config --global user.email "admin@example.com"

二、建立初始仓库

情景:初始仓库内容为空,需添加文件内容至初始仓库。下面列举两种添加方式:
一、克隆空仓库,进入相应文件夹添加文件并上传文件。
二、已存在待上传的项目文件,进入文件夹后以此文件夹内内容做为仓库内容并上传。
  • 流程图
    clipboard.png
  • 操做步骤ast

    • 建立新的目录和文件并上传至仓库class

      # Create a new repository
      git clone http://192.168.193.131/practice/project.git
      cd project
      touch README.md
      git add README.md
      git commit -m "add README"
      git push -u origin master
    • 已存在的目录和文件并上传至仓库email

      # Existing folder or Git repository
      cd existing_folder
      git init
      git remote add origin http://192.168.193.131/practice/project.git
      git add .
      git commit
      git push -u origin master

三、获取指定tag的版本

获取 openwrt tag 为 v18.06.2 的分支版本
  • tag 版本
    clipboard.png
  • git 命令cli

    git clone --branch v18.06.2 https://git.openwrt.org/openwrt/openwrt.git

4、参考资料

相关文章
相关标签/搜索