GitHub实际操作


###1. 基本操作

  • git init ——初始化仓库

$ mkdir git-tutorial
$ cd git-tutorial
$ git init
Initialized empty Git repository in F:/GitHub/git-tutorial/.git/
  • git status——查看仓库的状态

$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)
$ touch README.md
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        README.md

nothing added to commit but untracked files present (use "git add" to track)
  • git add——向暂存区中添加文件

  • git commit——保存仓库的历史记录

  • git log——查看提交日志

  • git diff——查看更改前后的区别

###2. 分支的操作

  • git branch——显示分支一览表

  • git checkout——创建切换分支

创建feature-A分支,并将当前分支切换为feature-A分支。这时再查看分支列表,会显示在feature-A分支下。

  • git merge——合并分支

  • git log --graph——以图表方式查看分支

###3. 更改提交的操作

  • git reset——回溯历史版本

  • 创建fix-B分支

  • 推进至feature-A分支合并后的状态

  • 消除冲突

Last updated

Was this helpful?