Version Control - A Brief Introduction to Gitcs356.yusun.io/slides/L05-Git.pdf · Git Basics...

Post on 17-Oct-2020

8 views 0 download

Transcript of Version Control - A Brief Introduction to Gitcs356.yusun.io/slides/L05-Git.pdf · Git Basics...

Version Control - A Brief Introduction to Git

CS356 Object-Oriented Design and Programming http://cs356.yusun.io October 8, 2014 !Yu Sun, Ph.D. http://yusun.io yusun@csupomona.edu

Why Version Control?

Maintain Multiple Versions

• Change version

• Safe backup

Collaboration The problem to avoid

Collaboration The lock-modify-unlock solution

Collaboration The copy-modify-merge solution

Collaboration The copy-modify-merge solution

Monitor and Track Progress

Code Difference

Code Contribution

Why Git?

Why Git?

• Performance  

• Github  

• Popular

Git History

Why Command-Line?

Why Git Command-Line?

• Graphical  clients  are  based  on  CLT  

• Graphical  clients  could  cause  problems  

• Integrated  with  shell  scripts  

• Graphical  clients  not  always  available

Git Exercises

1. Create Git Repositories

• git  clone  <repo>  

• git  init  <repo>

local repository

remote repository

local repository

local repository

2. Add/Commit/Push

• git  add  <path>  

• git  commit  

• git  push

working directory

staging area

local repository

remote repository

git add

git commit

git push

localremote

3. Check Status

• git  status  

• git  log  

• git  branch

4. Sync Changes & Resolve Conflicts

• git  pull  -­‐-­‐rebase        (referred  approach)        

• git  pull  

!

• git  status  

• clean  up  conflicts  

• git  add  <conflicted  file>  

• git  rebase  -­‐-­‐continue  

• git  push

local repository

remote repository

git pull

localremote

5. Branches

• git  checkout  -­‐b  <branch>  

• git  checkout  <branch>  

• git  merge  <branch>

Feature Branch

Master

6. Git Undo

• Always  backup  first  

• Google  the  soluAon

Git Learning Resources

• http://git-scm.com/

• https://www.youtube.com/user/GitHubGuides

• Google it!

Inclass Exercises

• Checkout git-exercise project

• Complete Exercise 1, 2, 3

• Finish Assignment 2

Git Basics Overview