version control
play

VERSION CONTROL Apr 30, 2019 Sprenkle - CS335 1 Review: Version - PDF document

VERSION CONTROL Apr 30, 2019 Sprenkle - CS335 1 Review: Version Control Why do we need version control? What is it good for? What are examples of version control systems? Using git How do we get code from the repository


  1. VERSION CONTROL Apr 30, 2019 Sprenkle - CS335 1 Review: Version Control • Why do we need version control? Ø What is it good for? • What are examples of version control systems? • Using git Ø How do we “get” code from the repository initially? Ø How do we put our code into the public version of the code? Ø How do we get code from the public version of the code? Apr 30, 2019 Sprenkle - CS335 2 1

  2. Backups and Coordination Issues • Maybe you wrote a paper and had several versions Ø Good practice to iterate over it! Ø Keep track of versions using names, e.g., paper1.pdf, paper.draft.pdf, paper.outline.pdf, paper.mar7.pdf • Coordinate a group Ø One person’s account has the version Ø Make conflicting changes to files • Figure out fix, Merge files Apr 30, 2019 Sprenkle - CS335 3 Version Control • Backup and Restore Ø Files are saved as they are edited Ø Revert to a specific version/checkpoint • Synchronization Ø Lets people share files Ø Stay up-to-date with the latest version • Track changes to code Ø Save comments explaining why change happened Ø Stored in the VCS, not the file Ø Track how, why a file evolves over time • Track Ownership Ø Tags every change with the name of the person who made it Apr 30, 2019 Sprenkle - CS335 4 2

  3. Version Control • Short-term undo Ø Messed up a file? Go back to the last good version • Long-term undo Ø Created a bug a year ago? Jump back to see change you made. • Sandboxing Ø Making a big change? Make temporary changes in isolated area, test, work out kinks before “checking in” your changes • Branching and merging Ø Branch a copy of your code into a separate area, modify it in isolation (tracking changes separately) Ø Later, merge work into common area. Apr 30, 2019 Sprenkle - CS335 5 Common Git Commands Command What it does add [file] Adds the file to the staging area commit Commits all the staged files (locally) push Push all your changes to the remote à You need your code to be pushed so that I can see it. branch List all local branches branch [name] Creates a new branch with that name Apr 30, 2019 Sprenkle - CS335 6 3

  4. Typical, Simple Workflow • Clone the project • Create a new branch, named by what you’re working on Ø Switch to that branch • Update files • When you’ve hit a good checkpoint, add the changed files to the “staging area” and then commit those files Ø Add a descriptive comment about what you’ve done. • Switch back to the “main” branch and merge in the branch you were working on • If you are ready to put your code on GitHub, push Apr 30, 2019 Sprenkle - CS335 7 Using Version Control • We’re using git, Users through Eclipse • Git is a distributed VCS Code • Have local repositories, GitHub own copy of code Repository • commit, update code • Keeps public copy of code Code Repositories store all versions of all files, comments about changes (“commit messages”, who made changes Apr 30, 2019 Sprenkle - CS335 8 4

  5. Using Version Control: clone clone • To start, need to clone the repository repository repository Repository repository Apr 30, 2019 Sprenkle - CS335 9 Using Version Control: commit commit • After you make changes that you want to document, commit your version Ø Include comments about what changes you made and why commit Local Code Code* comments? Repository comments • Updates each modified file • Records comments with updated files Apr 30, 2019 Sprenkle - CS335 10 5

  6. Using Version Control: push push • After you make changes that you want others to see, push your version Ø Comments à from your previous commits push GitHub Code Code* issues? Repository • Updates each modified file • Records comments with Code’ updated files Other people’s code doesn’t change Apr 30, 2019 Sprenkle - CS335 11 Using Version Control: pull pull • To see the current version of the code in the remote repository, pull Ø Resolve conflicts pull GitHub Code Repository code Apr 30, 2019 Sprenkle - CS335 12 6

  7. Using Version Control: add, delete add, delete • You need to add and delete files and directories to the staging area, then commit commit Local Code Repository • Add, delete files • Create new records for added files and directories • Close records for deleted files • Commit • Files not deleted from repository Apr 30, 2019 Sprenkle - CS335 13 Version Control Advice • Does not eliminate need for communication Ø Process becomes much more difficult if developers do not communicate • Write descriptive comments when you commit so your team members (and you!) know what you did and why • Push only after you’ve tested code and you’re fairly sure it works Apr 30, 2019 Sprenkle - CS335 14 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend