Git 基础培训

12月14日的时候在部门内组织了一次Git的基础培训,效果不太好。

对于效果为什么不好,我觉得有一些原因。

  • PowerPoint的演示我用得太少。我借了一个投影仪,用了复制模式。按理说我笔记本的屏幕应该和幕布应该显示同样的内容,但是,PowerPoint在播放的时候在笔记本上显示的演讲者模式,幕布上就用不一样的分辨率显示观众内容。这个是我始料未及的。由于分辨率的改变导致观众内容非常模糊,所以在前半部分根本在和银幕做斗争。后来,我干脆不播放PPT,直接在Bash窗口里打我的命令,效果反而好些。
  • 准备的东西有点儿多,进程也编排得有点花哨。忽略了受众是常年用SVN,对分布式版本控制完全没有概念的。解释起来有一定的难度。应该拆成两个培训,可能效果会好一些。
  • 下次如果有机会再做这类的培训,我会选择Jupyter Notebook来做演示;或者写扁平风格的PPT来做,不要动画效果,朴实一些。

我准备的材料差不多是下面的这些。

0

Centralized VCS: designed with the intent that there is One True Source that is Blessed, and therefore Good.

Distributed VCS: systems are designed with the intent that one repository is as good as any other.

1 Git

Since 2005 created by Linus Torvalds

Installations

Linux: apt-get install git
Windows: Git for Windows(Git Bash)/TortoiseGit/SourceTree

Basic configurations

git config –global user.name “Your name”
git config –global user.email [email protected]
git config –global color.ui true

Commands

Basic Commands

  • init
  • add
  • commit
  • status
  • log
  • diff
  • show
  • mv
  • rm
  • reset

Branch Related Commands

  • branch
  • checkout
  • merge
  • rebase

Collaborating Commands

  • clone
  • fetch
  • push
  • pull

2 Basic Workflow

Like SVN

  • git init
  • git status
  • git add
  • git commit
  • git log
  • git diff
  • git tag

Branching

  • git branch
  • git checkout –b xxx
  • git merge xxx

Stashing

  • git stash
  • git stash apply
  • git stash pop
  • git stash drop
  • git stash list

3 Collaborating with Other Colleagues

GitLab or GitHub

Creating Repositories

Cloning others’ Repository

Collaborating Commands

4 Other Tips

I am so sorry that I have done these…

  • git checkout — files
  • git reset –hard/–soft

I can ignore the conflicts, using mine…

  • git checkout –ours/–theirs

I need one node, instead of whole branch

  • git cherry-pick

What have I done in this repo?

  • git reflog

Comprehensive logs

  • git log v2.5.. # commits since (not reachable from) v2.5
  • git log test..master # commits reachable from master but not test
  • git log master..test # commits reachable from test but not master
  • git log master…test # commits reachable from either test or master, but not both
  • git log –since=”2 weeks ago” # commits from the last 2 weeks
  • git log Makefile # commits that modify Makefile
  • git log –no-merges # dont show merge commit

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据