part 0 git ing started part 1 essential skills part 2
play

Part 0: Git-ing Started Part 1: Essential Skills Part 2: - PowerPoint PPT Presentation

Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Comic Credit: Randall Munroe, xkcd.com Lab 3: Version Control Part 0: Git-ing Started Part 1: Essential Skills Part 2:


  1. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Comic Credit: Randall Munroe, xkcd.com Lab 3: Version Control

  2. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Lab 3: Version Control CS 2112 Fall 2020 September 21 / 23, 2020 Lab 3: Version Control

  3. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Why 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! Lab 3: Version Control

  4. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells One-Time Setup Download Git If you are comfortable with the command line, Git / Git Bash is a powerful tool that gives you full control over your repository: https://git-scm.com/downloads If you prefer a graphical interface, GitHub Desktop is an application developed by GitHub to streamline the process of working with their hosted repositories. It is sufficient for almost all use-cases covered in this class: https://desktop.github.com Lab 3: Version Control

  5. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells One-Time Setup Configure Git (Terminal) If you’re using git on the terminal, enter the following two commands to set up your name and email: git config --global user.name "<Your Name >" 1 git config --global user.email <netid >@cornell.edu 2 Lab 3: Version Control

  6. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells One-Time Setup Configure GitHub Desktop If you’re using GitHub Desktop, on first launch, choose “Sign in to GitHub Enterprise Server” Then enter github.coecis.cornell.edu as the server and login with your netid (without @cornell.edu ) and password. Finally, enter your name and Cornell email on the next screen. Lab 3: Version Control

  7. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Creating a Repository Repository Git calls a project a “repository”. Go to https://github.coecis.cornell.edu and login with your netid to get started. Note: for future assignments in this class, we will be assigning you a repository. Lab 3: Version Control

  8. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Creating a Repository Creating the Repository Click the plus sign in the top right to make a new repository. Enter a repository name, choose “Private” for privacy, and check “Initialize with a README.” VERY IMPORTANT: You MUST remember to make your repositories private. Academic integrity is enforced very strictly at Cornell and you do not want to open yourself to potential liability. Lab 3: Version Control

  9. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Creating a Repository Adding Collaborators From the repository’s main page, choose “Settings” → “Collaborators” and enter their Cornell emails. Lab 3: Version Control

  10. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Creating a Repository Cloning a Repo From the repository’s main page, click the green “Clone or Download” button. For GitHub Desktop users, choose “Open in Desktop”. For terminal users, copy the provided link. Lab 3: Version Control

  11. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Creating a Repository Cloning a Repo From GitHub Desktop, click the “Choose” button to select where to clone your repo. On the terminal, cd to the directory you want and then run git clone <PASTE> (where <PASTE> is where you paste the link from the last slide). For class projects, clone into your Eclipse workspace. For this lab, clone to your Desktop. Lab 3: Version Control

  12. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Workflow The Workflow The three main steps: 1) Commit - Confirm the changes you’ve made 2) Push - Sync your changes to the server 3) Pull - Sync down changes from the server Lab 3: Version Control

  13. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Workflow 1) Commit To demonstrate, create a file with some text in it. On terminal, run git add <filename> followed by git commit -m "<description>" . On GitHub Desktop, type the commit description into the Commit Message box and click Commit. Lab 3: Version Control

  14. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Workflow 2) Push Get your changes onto the remote server: On terminal, run git push . On GitHub Desktop, click the “Push origin” button in the top right. Lab 3: Version Control

  15. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Workflow 3) Pull From the other computer: On terminal, run git pull . On GitHub Desktop, click the “Fetch” button in the top right twice - once to fetch, again to pull. Lab 3: Version Control

  16. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Merging Changes Automatic Merge If two people edit different files or different parts of the same file, the second person to push will fail. Instead, they will first need to pull the changes. Git will automatically merge the changes from both users by creating a new “Merge Commit.” Then, push again. This time, it should go through. Lab 3: Version Control

  17. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Merging Changes Merge Conflicts If two people edit the same parts of the same file, then Git will not be able to automatically merge and you will have a merge conflict. Open the conflicting file and you will see something like this: <<<<<<< HEAD 1 Your changes 2 ======= 3 Partner changes 4 >>>>>>> 123456789 5 Git is marking which parts of the file conflict. Just delete what you don’t want, keep what you do, and then run git commit again (GitHub Desktop will prompt you automatically). Lab 3: Version Control

  18. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells 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 your collaborators. ◮ Recover any files if they are lost. ◮ Merge changes between multiple people’s contributions Lab 3: Version Control

  19. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Version Control Types of Version Control Centralized Version Control Distributed Version Control One central repository stored on Every user keeps a full copy of a server. Users can check out the repository. Changes can be portions of the repository to pushed from any repo to any their local machine for other, though usually, a single development. repository (usually hosted on a Examples include Subversion server, like GitHub) is and Perforce. designated as the main one. Examples include Git and Mercurial. Lab 3: Version Control

  20. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Version Control Version Control Software Several widely used version control systems exist. Some of the most popular free ones are Git, Mercurial, and Subversion. Perforce is sometimes used in industry. We will use Git, which is freely available, powerful, and rapidly becoming the de facto standard. Subversion is a bit simpler to use but less powerful. Mercurial is very similar to Git, though less popular. Eclipse has some support for projects that use Git, but it’s generally preferred to use separate Git tools. Lab 3: Version Control

  21. Part 0: Git-ing Started Part 1: Essential Skills Part 2: Introduction to Git Part 3: Advanced Features Part 4: Shells Useful Features Git Log GitHub Desktop shows you a running chronological log of all the commits in your repository and the changes made. On terminal, you can run git log to see the same information. Lab 3: 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