Download presentation
Presentation is loading. Please wait.
1
Version Control with Git
Version Control with Git
2
Why track/manage revisions?
3
Backup: Undo or refer to old stuff
4
Branch: Maintain old release while working on new
5
Collaborate: Work in parallel with teammates
6
Version Control Systems (VCSs)
Help you track/manage/distribute revisions Standard in modern development Examples: Revision Control System (RCS) Concurrent Versions System (CVS) Subversion (SVN) Git older Our focus newer
7
Distributed VCSs (DVCSs) Git is one!
8
Distributed VCSs (DVCSs) Git is one!
Server has shared copy of repos
9
Distributed VCSs (DVCSs) Git is one!
Clients have working directory + repos copy
10
Distributed VCSs (DVCSs) Git is one!
Clients may share via server or with each other directly
11
GitHub-User Perspective
You GitHub Working Dir Local Repos Remote Repos
12
Let’s begin with an example…
You GitHub
13
Configure your Git client (Rails Tutorial 1.3.1)
Install Git Check config info: Fix if necessary: $ git config --list user.name=Scott Fleming $ git config --global user.name "John Doe" $ git config --global user.
14
Log into GitHub and create a repos (with add README option)
You GitHub Remote Repos
15
$ git clone https://github.com/sdflem/comp4081_demo.git
You GitHub Local Repos Working Dir Remote Repos
16
You GitHub Working Dir Local Repos Remote Repos
$ rails new comp4081_demo You GitHub Local Repos Working Dir Remote Repos
17
$ cd comp4081_demo $ git add . $ git commit
You GitHub Local Repos Working Dir Remote Repos
18
File Status Lifecycle git add??? git add git commit git rm???
19
$ git push You GitHub Local Repos Working Dir Remote Repos
20
Questions to answer How organized? You GitHub What operations?
Local Repos Working Dir Remote Repos What operations?
21
How the repos is organized
22
How the repos is organized
Commits (from oldest to newest; hashes as commit IDs)
23
How the repos is organized
Snapshot of all files at each commit
24
How the repos is organized
Branch (last commit)
25
How commit works Before
26
How commit works After
27
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos Make changes in local branch Merge with GitHub repos
28
Organization with two branches
29
Organization with two branches
Last commit of each branch
30
Organization with two branches
Currently checked out branch
31
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
32
How git branch works $ git branch testing Before
33
How git branch works $ git branch testing After
34
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
35
How git checkout works $ git checkout testing Before
36
How git checkout works $ git checkout testing After
37
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
38
How git commit works with multiple branches
Edit some stuff $ git commit -a Before
39
How git commit works with multiple branches
Edit some stuff $ git commit -a After
40
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
41
How git checkout works $ git checkout master Before
42
How git checkout works $ git checkout master After
43
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
44
How git pull works Someone else pushed $ git pull Before
45
How git pull works Someone else pushed $ git pull After
46
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
47
How git merge works $ git merge testing Before
48
How git merge works $ git merge testing e2b92 After
49
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
50
How to delete branches $ git branch -d testing e2b92 Before
51
How to delete branches $ git branch -d testing e2b92 After
52
Common Workflow Create temp local branch Checkout temp branch
Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
53
How git push works Should update server repos $ git push
e2b92 Should update server repos (if no one else has pushed commits to master branch since last pull)
54
Tips git output contains lots of hints
git status is your friend! Merging may not be as easy as I showed E.g.: Multiple collabs updated same parts of file See Pro Git 3.2 Pull before starting temp branch Team communication important!
55
Pair Activity Share one GitHub repos Practice parallel editing/merging
two different files (FOO.txt/BAR.txt) different parts (top/bottom) of same file (FOO.txt) same line of same file (FOO.txt)
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.