常用指令

  • GIT 查看/修改用户名和邮箱地址

    1. 用户名和邮箱地址的作用

      用户名和邮箱地址是本地git客户端的一个变量,不随git库而改变。

      每次commit都会用用户名和邮箱纪录。

      github的contributions统计就是按邮箱来统计的。

    2. 查看用户名和邮箱地址

      1
      2
      3
      $ git config user.name

      $ git config user.email
    3. 修改用户名和邮箱地址

      1
      2
      3
      $ git config --global user.name "username"

      $ git config --global user.email "email"

在配置好git之后,有一套完整的操作流程,推荐看pro git这本书。git的文档:https://git-scm.com/

  • 把修改暂存到本地 git add
  • 把本地修改进行提交 git commit
  • 把本地提交上传到远程仓库 git push
  • 将远程仓库的最新内容拉到本地 git fetch
  • 将更新与本地合并 git merge
  • 查看现在的分支 git branch
  • 创建新分支 git branch newbranchname
  • 切换分支 git checkout newbranchname
  • 查看不同提交的历史 git log

push到远程的分支可以在github上申请merge request,然后由仓库管理员将其合并到主分支,然后close该MR。