git and
t he vi r t ue
- f
ver si
- n
cont r
- l
ECE 18-545 Fall 2016
Brandon Lucia
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
ECE 18-545 Fall 2016
Brandon Lucia
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
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)
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
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.
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 }
Repository $>git init $>cd 545proj
Repository $>git init Creates an empty, local repository for Creates a .git directory with repo metadata for
new repo
$>cd 545proj
Repository
repo
$>git add
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
Repository
repo
$>git commit -m “added ”
staging area
Repository
repo
$>git commit -m “added ”
staging area
commit removes the file from the staging area and commits it to the repo
message with the commit. be descriptive!
Repository
repo
Repository
repo
Repository
repo
$>git remote add origin git@github.com:pikachu/545proj.git
repo
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
Repository
repo
$>git push origin master
repo
Repository
repo
$>git push origin master
repo
pushes ’s changes to the repo to the remote called origin push changes on the “master”
Repository
repo repo
Repository
repo repo
$>git clone git@github.com:pikachu/545proj.git
Repository
repo
$>git clone git@github.com:pikachu/545proj.git
repo
repo
clones the repository from GitHub into ’s local repository
Repository
repo
$>cat >
repo
repo
$>add $>commit -m “ !” $>cat > $>add $>commit -m “ !”
Repository
repo
$>
repo repo
$>git push origin master
Repository
repo
$>git pull origin master
repo repo
$>
Repository
repo
$>git push origin master
repo repo
$>
Repository
repo
$>
repo repo
$>git pull origin master
Repository
repo
$>
repo repo
$>git pull origin master
Summary: usually want to “git pull” often to collect your teammates edits
Repository
repo
$>
repo repo
$>git commit -m “ !”
$>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.
repo
$>git commit -m “ !”
$>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
Repository
repo
$>
repo repo
$>git commit -m “ !”
$>git push origin master $>git add
Repository
repo
$>git pull origin master
repo repo
$>
$>git log
commit 7a44d6a8dad0234d7f1b5c8c0112b3e532b96b1f Author: Pikachu <pikachu@pokemon.com> Date: Wed May 27 20:40:18 2015 -0400
$>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!
$>git checkout -b experimental master experimental
master experimental $>git push origin\
experimental
master experimental
master experimental $>git branch
* experimental master
master experimental $>git checkout master
experimental * master
master experimental $>git merge experimental master $>git branch -d experimental $>git push origin master
repo repo repo
$>git remote add ash\ http://ash.tv/545proj.git
$>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
repo repo repo
master
experimental
master master master starthing mybranch
$>git fetch blastoise starthing $>git merge starthing master <deal with conflicts…>
master
experimental
repo
master starthing
ashketchum / shapes
Added magenta circles to star
master
experimental
Added magenta circles to star
blastoise shapes: master blastoise blastoise Added some cool magenta circles to the start thing
shapes: starthing
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: