version control
play

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


  1. git and t he vi r t ue of ver si on cont r ol ECE 18-545 Fall 2016 Brandon Lucia

  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

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

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

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

  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 }

  7. Initializing a New Repo Repository $>cd 545proj $>git init

  8. Initializing a New Repo Repository Creates an empty , local repository for new repo Creates a .git directory with repo metadata for $>cd 545proj $>git init

  9. Contributing to a Repo Repository repo $>git add

  10. Contributing to a Repo Repository add Expresses that a file, like is changed (or created, here) repo staging area add puts the changed file in the repo’s “staging area” for $>git add

  11. Contributing to a Repo Repository repo staging area $>git commit - m “added ”

  12. Contributing to a Repo Repository commit removes the file from the staging area and commits it to the repo repo - m “blah blah” associates a staging area message with the commit. be descriptive! $>git commit - m “added ”

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

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

  15. Syncing with a Remote Repo (e.g., GitHub) Repository repo repo $> git remote add origin git@github.com:pikachu/545proj.git

  16. Syncing with a Remote Repo (e.g., GitHub) Repository repo repo adds a remote , naming it “origin” and pointing it at your github $> git remote add origin git@github.com:pikachu/545proj.git

  17. Syncing with a Remote Repo (e.g., GitHub) Repository repo repo $> git push origin master

  18. Syncing with a Remote Repo (e.g., GitHub) Repository repo repo ’s changes to the repo push es to the remote called origin $> git push origin master push changes on the “master” branch . (wait a coupla slides.)

  19. Collaborating with GitHub Repository repo repo

  20. Collaborating with GitHub Repository repo repo $> git clone git@github.com:pikachu/545proj.git

  21. Collaborating with GitHub Repository repo repo repo clone s the repository from GitHub into ’s local repository $> git clone git@github.com:pikachu/545proj.git

  22. Combining Compatible Changes Repository repo repo repo $>cat > $>cat > $>add $>add $>commit - m “ !” $>commit - m “ !”

  23. Combining Compatible Changes Repository repo repo repo $> $>git push origin master

  24. Combining Compatible Changes Repository repo repo repo $>git pull origin master $>

  25. Combining Compatible Changes Repository repo repo repo $>git push origin master $>

  26. Combining Compatible Changes Repository repo repo repo $> $>git pull origin master

  27. Combining Compatible Changes Repository repo repo repo $> $>git pull origin master Summary: usually want to “git pull” often to collect your teammates edits

  28. Merge Conflicts 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.

  29. Merge Conflicts black outer circle blue square repo black outer circle <<<<<< HEAD blue square green circle $>vi magenta circle ====== red circle >>>>>>> master $>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.

  30. Merge Conflicts Repository repo repo repo $> $>git add $>git commit - m “ !” $>git push origin master

  31. Conflict Resolved Repository repo repo repo $>git pull origin master $>

  32. Looking at History commit 7a44d6a8dad0234d7f1b5c8c0112b3e532b96b1f Author: Pikachu <pikachu@pokemon.com> Date: Wed May 27 20:40:18 2015 -0400 $>git log

  33. Reverting to History commit 7a44d6a8dad0234d7f1b5c8c0112b3e532b96b1f Author: Pikachu <pikachu@pokemon.com> Date: Wed May 27 20:40:18 2015 -0400 $>git revert --no-commit 7a44d6a..HEAD Note: “HEAD” means your current commit Also: only need start of commit hash Also: lots of ways to go back… be careful!

  34. Branching: Non-linear History experimental $> git checkout -b experimental master

  35. Branching: Non-linear History experimental $> git push origin\ experimental master master experimental

  36. Branching: Non-linear History experimental master $> git branch * experimental master

  37. Branching: Non-linear History experimental master $> git checkout master experimental * master

  38. Merging Branches experimental master $> git merge experimental master $> git branch -d experimental $> git push origin master

  39. Advanced Features You Probably Won’t Need for 545

  40. Fully Distributed Version Control $>git remote add blastoise\ http://blastoi.se/545proj.git $>git remote add raichu\ http://raichu.biz/545proj.git repo repo repo $>git remote add ash\ $>git remote add ash\ http://ash.tv/545proj.git http://ash.tv/545proj.git $>git remote add blastoise\ $>git remote add raichu\ http://blastoi.se/545proj.git http://raichu.biz/545proj.git

  41. Fully Distributed Version Control $>git fetch blastoise starthing master $>git merge starthing master <deal with conflicts…> repo repo repo mybranch experimental starthing experimental master master master master

  42. Asking Someone to Pull Your Changes ashketchum / shapes repo Added magenta circles to star starthing experimental master master

  43. Asking Someone to Pull Your Changes Added magenta circles to star shapes: blastoise shapes: starthing master blastoise Added some cool magenta circles to the start thing blastoise

  44. Version Control Great Tutorials & Reference Info: https://www.atlassian.com/git/tutorials/ 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

Recommend


More recommend