Version Control What is it? A tool for collaborative editing A - - PowerPoint PPT Presentation

version control
SMART_READER_LITE
LIVE PREVIEW

Version Control What is it? A tool for collaborative editing A - - PowerPoint PPT Presentation

git and t he vi r t ue of ver si on cont r ol ECE 18-545 Fall 2016 Brandon Lucia Version Control What is it? A tool for collaborative editing A tool for keeping an edit history A tool for managing edit versions For the code in


slide-1
SLIDE 1

git and

t he vi r t ue

  • f

ver si

  • n

cont r

  • l

ECE 18-545 Fall 2016

Brandon Lucia

slide-2
SLIDE 2

Version Control

What is it? A tool for collaborative editing A tool for keeping an edit history A tool for managing edit versions

For the code in your project

slide-3
SLIDE 3

Version Control

to back up your code somewhere else to track all the changes anyone commits to roll back to a prior copy (as needed) to manage merging concurrent edits to permit branching for divergent edits What are we going to use it for? (to show off your work after you’re done)

slide-4
SLIDE 4

Version Control

Which one are we going to use? Today: I’ll show you how you’ll use git & GitHub to manage your projects GitHub, a web-based git solution

slide-5
SLIDE 5

Version Control

Why GitHub? Centrally managed, easy UI, well supported Bonus: your GitHub goes on your resume when you graduate. Show off! You will probably come across this again in the future.

slide-6
SLIDE 6

Version Control

typedef struct { interrupt_type_t type; uint16_t id; uint8_t features; } interrupt_context_t; static state_t state = STATE_OFF; static uint16_t debug_flags = 0; static interrupt_context_t interrupt_context; volatile uint16_t __fram _libedb_internal_breakpoints = 0x00; static uint16_t *wisp_sp; // stack pointer on debug entry static uint8_t uartRxBuf[CONFIG_DEBUG_UART_BUF_LEN]; static uint8_t cmd_data_buf[WISP_CMD_MAX_LEN]; static void set_state(state_t new_state) { #ifdef CONFIG_STATE_PINS uint8_t port_value; #endif state = new_state; #ifdef CONFIG_STATE_PINS // Encode state onto two indicator pins port_value = GPIO(PORT_STATE, OUT); port_value &= ~(BIT(PIN_STATE_0) | BIT(PIN_STATE_1)); // clear port_value |= (new_state & 0x1 ? BIT(PIN_STATE_0) : 0) | (new_state & 0x2 ? BIT(PIN_STATE_1) : 0); GPIO(PORT_STATE, OUT) = port_value; #endif }

slide-7
SLIDE 7

Initializing a New Repo

Repository $>git init $>cd 545proj

slide-8
SLIDE 8

Initializing a New Repo

Repository $>git init Creates an empty, local repository for Creates a .git directory with repo metadata for

new repo

$>cd 545proj

slide-9
SLIDE 9

Contributing to a Repo

Repository

repo

$>git add

slide-10
SLIDE 10

Contributing to a Repo

Repository

repo

$>git add

staging area

add Expresses that a file, like is changed (or created, here) add puts the changed file in the repo’s “staging area” for

slide-11
SLIDE 11

Contributing to a Repo

Repository

repo

$>git commit -m “added ”

staging area

slide-12
SLIDE 12

Contributing to a Repo

Repository

repo

$>git commit -m “added ”

staging area

commit removes the file from the staging area and commits it to the repo

  • m “blah blah” associates a

message with the commit. be descriptive!

slide-13
SLIDE 13

Syncing with a Remote Repo (e.g., GitHub)

Repository

repo

slide-14
SLIDE 14

Syncing with a Remote Repo (e.g., GitHub)

Repository

repo

slide-15
SLIDE 15

Syncing with a Remote Repo (e.g., GitHub)

Repository

repo

$>git remote add origin git@github.com:pikachu/545proj.git

repo

slide-16
SLIDE 16

Syncing with a Remote Repo (e.g., GitHub)

Repository

repo

$>git remote add origin git@github.com:pikachu/545proj.git adds a remote, naming it “origin” and pointing it at your github

repo

slide-17
SLIDE 17

Syncing with a Remote Repo (e.g., GitHub)

Repository

repo

$>git push origin master

repo

slide-18
SLIDE 18

Syncing with a Remote Repo (e.g., GitHub)

Repository

repo

$>git push origin master

repo

pushes ’s changes to the repo to the remote called origin push changes on the “master”

  • branch. (wait a coupla slides.)
slide-19
SLIDE 19

Collaborating with GitHub

Repository

repo repo

slide-20
SLIDE 20

Repository

repo repo

Collaborating with GitHub

$>git clone git@github.com:pikachu/545proj.git

slide-21
SLIDE 21

Repository

repo

$>git clone git@github.com:pikachu/545proj.git

repo

Collaborating with GitHub

repo

clones the repository from GitHub into ’s local repository

slide-22
SLIDE 22

Repository

repo

$>cat >

repo

Combining Compatible Changes

repo

$>add $>commit -m “ !” $>cat > $>add $>commit -m “ !”

slide-23
SLIDE 23

Repository

repo

$>

repo repo

$>git push origin master

Combining Compatible Changes

slide-24
SLIDE 24

Repository

repo

$>git pull origin master

repo repo

$>

Combining Compatible Changes

slide-25
SLIDE 25

Repository

repo

$>git push origin master

repo repo

$>

Combining Compatible Changes

slide-26
SLIDE 26

Repository

repo

$>

repo repo

$>git pull origin master

Combining Compatible Changes

slide-27
SLIDE 27

Repository

repo

$>

repo repo

$>git pull origin master

Combining Compatible Changes

Summary: usually want to “git pull” often to collect your teammates edits

slide-28
SLIDE 28

Repository

repo

$>

repo repo

$>git commit -m “ !”

Merge Conflicts

$>git pull origin master

* branch master -> FETCH_HEAD Auto-merging CONFLICT (content): Merge conflict in Automatic merge failed; fix conflicts and then commit the result.

slide-29
SLIDE 29

repo

$>git commit -m “ !”

Merge Conflicts

$>git pull origin master

* branch master -> FETCH_HEAD Auto-merging CONFLICT (content): Merge conflict in Automatic merge failed; fix conflicts and then commit the result.

$>vi

black outer circle blue square <<<<<< HEAD green circle ====== red circle >>>>>>> master black outer circle blue square magenta circle

slide-30
SLIDE 30

Repository

repo

$>

repo repo

$>git commit -m “ !”

Merge Conflicts

$>git push origin master $>git add

slide-31
SLIDE 31

Repository

repo

$>git pull origin master

repo repo

Conflict Resolved

$>

slide-32
SLIDE 32

Looking at History

$>git log

commit 7a44d6a8dad0234d7f1b5c8c0112b3e532b96b1f Author: Pikachu <pikachu@pokemon.com> Date: Wed May 27 20:40:18 2015 -0400

slide-33
SLIDE 33

Reverting to History

$>git revert --no-commit 7a44d6a..HEAD

commit 7a44d6a8dad0234d7f1b5c8c0112b3e532b96b1f Author: Pikachu <pikachu@pokemon.com> Date: Wed May 27 20:40:18 2015 -0400

Note: “HEAD” means your current commit Also: only need start of commit hash Also: lots of ways to go back… be careful!

slide-34
SLIDE 34

Branching: Non-linear History

$>git checkout -b experimental master experimental

slide-35
SLIDE 35

Branching: Non-linear History

master experimental $>git push origin\

experimental

master experimental

slide-36
SLIDE 36

Branching: Non-linear History

master experimental $>git branch

* experimental master

slide-37
SLIDE 37

Branching: Non-linear History

master experimental $>git checkout master

experimental * master

slide-38
SLIDE 38

Merging Branches

master experimental $>git merge experimental master $>git branch -d experimental $>git push origin master

slide-39
SLIDE 39

Advanced Features You Probably Won’t Need for 545

slide-40
SLIDE 40

repo repo repo

$>git remote add ash\ http://ash.tv/545proj.git

Fully Distributed Version Control

$>git remote add blastoise\ http://blastoi.se/545proj.git $>git remote add ash\ http://ash.tv/545proj.git $>git remote add blastoise\ http://blastoi.se/545proj.git $>git remote add raichu\ http://raichu.biz/545proj.git $>git remote add raichu\ http://raichu.biz/545proj.git

slide-41
SLIDE 41

repo repo repo

Fully Distributed Version Control

master

experimental

master master master starthing mybranch

$>git fetch blastoise starthing $>git merge starthing master <deal with conflicts…>

master

experimental

slide-42
SLIDE 42

repo

Asking Someone to Pull Your Changes

master starthing

ashketchum / shapes

Added magenta circles to star

master

experimental

slide-43
SLIDE 43

Added magenta circles to star

blastoise shapes: master blastoise blastoise Added some cool magenta circles to the start thing

Asking Someone to Pull Your Changes

shapes: starthing

slide-44
SLIDE 44

Version Control

TODO: make a GitHub account by going to http://github.com TODO: elect one person in your group to initialize the project and to add other members as collaborators on GitHub TODO: everyone contributes a modification to the README https://www.atlassian.com/git/tutorials/ Great Tutorials & Reference Info: