cs 2112 lab version control
play

CS 2112 Lab: Version Control CS 2112 Lab: Version Control What is - PowerPoint PPT Presentation

What is Version Control? Git Structure Using Git Controlling your computer with a shell CS 2112 Lab: Version Control CS 2112 Lab: Version Control What is Version Control? Git Structure Using Git Controlling your computer with a shell


  1. What is Version Control? Git Structure Using Git Controlling your computer with a shell CS 2112 Lab: Version Control CS 2112 Lab: Version Control

  2. What is Version Control? Git Structure Using Git Controlling your computer with a shell Version Control What is Version Control? You’re emailing your project back and forth with your partner. An hour before the deadline, you and your partner both find different bugs and work feverishly to correct them. When you try to submit, you find that you have two different versions of the code, and you don’t have enough time to figure out who changed what, how to merge them together into one final project, and what, if any, bugs were introduced along the way! CS 2112 Lab: Version Control

  3. What is Version Control? Git Structure Using Git Controlling your computer with a shell Version Control What is Version Control? Version control allows multiple people to work on a project simultaneously by keeping versioned copies of each file in your project for each edit that you make. This makes it easy to: ◮ Revert files back to a previous state if you make a mistake. ◮ Look over any changes made by you or those you are working with. ◮ Recover any files if they are lost. Distributed version control lets you store the different versions of your files on a remote server. CS 2112 Lab: Version Control

  4. What is Version Control? Git Structure Using Git Controlling your computer with a shell Overview Git! Several widely used version control systems exist. Some of the most popular free ones are Git, Mercurial, and Subversion. Perforce is often used in industry. We will take a look at Git, which is popular, freely available, and powerful. Subversion is simpler to use but less powerful; Mercurial is similar to Git; perhaps a little slower. Eclipse has some support for projects that use Git, but it’s safer to get Git at the command line. CS 2112 Lab: Version Control

  5. What is Version Control? Git Structure Using Git Controlling your computer with a shell Overview Setting Up a Repository A couple of sites host free repositories, including: ◮ github.com (Git - though you will need to request a student account for private repositories) ◮ bitbucket.org (Git and Mercurial) ◮ xp-dev.com (Subversion, Git, and Mercurial) You will need to follow the specific instructions for whichever host you choose in order to initialize a Git project and add your new remote repository. (This will make more sense later!) CS 2112 Lab: Version Control

  6. What is Version Control? Git Structure Using Git Controlling your computer with a shell Structure The Local Repository Your local repository contains 3 trees : ◮ Working Directory - This is where you will look at, modify, and add files to your project. ◮ Staging Area/Index - When you add a file ( git add � file � from the command line, or Add to Index in Eclipse), the file is added to this second tree, the staging area. This is where you prepare the files that you would like to eventually commit to your repository. ◮ Repository - When you commit the changes made to your files ( git commit by command line, Commit in Eclipse), changes made to the files in your staging area are added to the repository as new versions of those files. You must specify a commit message with each commit to let others know what you have changed. CS 2112 Lab: Version Control

  7. What is Version Control? Git Structure Using Git Controlling your computer with a shell Structure The Local Repository Figure: Local Repository Workflow CS 2112 Lab: Version Control

  8. What is Version Control? Git Structure Using Git Controlling your computer with a shell Structure The Remote Repository ◮ When you are ready for others on your team to be able to view and pull your changes into their own local repositories, you can push your committed changes to the remote repository. ◮ If anyone else has pushed changes to your remote repository, Git will make you pull those changes into your own local repository before pushing any new changes. ◮ If you and your partner have been working on different parts of your code, Git will automatically merge in your partner’s changes smoothly. If you have been working on the same code, however... CS 2112 Lab: Version Control

  9. What is Version Control? Git Structure Using Git Controlling your computer with a shell Structure The Remote Repository Figure: Remote repository workflow CS 2112 Lab: Version Control

  10. What is Version Control? Git Structure Using Git Controlling your computer with a shell Conflicts and Reverting Merge conflicts If you and your partner have both modified the same code, Git will be unsure about which version you would like it to use - yours, or theirs? To fix this, Git will ask you to resolve merge conflicts. Figure: Eclipse Merge Conflict Tool CS 2112 Lab: Version Control

  11. What is Version Control? Git Structure Using Git Controlling your computer with a shell Conflicts and Reverting Merge conflicts Once you have your Local File Workspace version of the file looking how you would like, you can right click on the file to mark it as merged. You can then commit your merge, and push it as normal. CS 2112 Lab: Version Control

  12. What is Version Control? Git Structure Using Git Controlling your computer with a shell Conflicts and Reverting Git Workflow - Reverting a File Figure: A Git Workflow CS 2112 Lab: Version Control

  13. What is Version Control? Git Structure Using Git Controlling your computer with a shell Conflicts and Reverting EGit Commands to Remember! ◮ Team → Add to Index — Add a file to your Index if you want to track the changes you make in it, and commit those changes later. ◮ Team → Commit — Commit changes in your working directory to your local repository; these changes will be pushed to the remote repository on the next Push command. ◮ Team → Synchronize Workspace — This will pull from the remote repository and make sure that your local repository is up to date (needed especially before a Push) ◮ Push or Team → Push Branch — Pushes all your committed changes to the remote repository CS 2112 Lab: Version Control

  14. What is Version Control? Git Structure Using Git Controlling your computer with a shell The shell: a lower-level interface A shell is a command-line interface to your computer’s operating system. Less pretty than the GUI interface, more functional. ◮ Windows: cmd, Cygwin (Unix on Windows), or PowerShell ◮ Unix (Mac OS X, Linux): sh (bash), (t)csh CS 2112 Lab: Version Control

  15. What is Version Control? Git Structure Using Git Controlling your computer with a shell Shell commands A shell command consists of a program name followed by some optiona command-line arguments. Spaces separate the command and the arguments from each other. Examples: ◮ rm � filename � (Windows: del � filename � ) : remove a file ◮ ls � directory � (Windows: dir � directory � ): list contents of directory ◮ echo � message � : print the message to standard output ◮ cat � filename � (Windows: type � filename � ) : print the contents of the file. ◮ cd � directory � : change the current directory (shell built-in command) CS 2112 Lab: Version Control

  16. What is Version Control? Git Structure Using Git Controlling your computer with a shell Command context Every command is executed with some context provided by the operating system: ◮ The current directory in which the command runs. All files accesses are relative to this directory. Note: folders are known as directories at the operating system level. ◮ A set of environment variables that can be looked up by the running program. 1 ◮ Standard input and output devices. Normally standard input reads from the shell’s input and output goes to the shell. However, it is possible to override these. The syntax > � filename � redirects output to the specified file. 1 The ShellShock vulnerability exploits a bug in how the bash shell handles environment variables. CS 2112 Lab: Version Control

  17. What is Version Control? Git Structure Using Git Controlling your computer with a shell Pathnames and directories ◮ Files and directories are specified by pathnames : names separated by slashes (Unix, Cygwin) or backslashes (Windows). ◮ Pathnames starting with a slash (backslash) are absolute and start from the root of the file system. ◮ The special directory “.” means the current directory, and “..” means the parent directory of the current directory. ◮ To go up a directory: cd .. ◮ To go to the root directory: cd / ◮ To list the current directory: ls . , or just ls . CS 2112 Lab: Version Control

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