Introduction to Git

Git? Github?

Same? Different?

Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. ~wikipedia

GitHub is a web-based Git...It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. ~wikipedia

Version Control? Why?

  • revert files back to a previous state
  • revert the entire project back to a previous state
  • compare changes over time
  • see who last modified something
  • backup files

Getting started

Install Git

https://git-scm.com/downloads

download

create a new repository

$ git init

checkout a repository

$ git clone 
  username@host:/path/to/repo

Workflow

Workflow

Working Directory

Staging

Repo

Add

add file(s) from working directory to staging

$ git add <filename>

$ git add *

Commit

commit file(s) from staging to local repository

$ git commit -m "Commit message"

Pushing changes

push changes to remote repository

$ git push origin master

progress

Photo openshift.com

Branching

used to develop features isolated from each other

branches

$ git checkout -b feature_x

update

$ git pull

merge

$ git merge <branch>

merge conflicts

merge

merge conflicts resolved

merged

branches sample

Photo githubusercontent.com

Credits and Sources

https://hshaosf.github.io/talks-introduction-to-git/