Presentation is loading. Please wait.

Presentation is loading. Please wait.

Git CS 110 - Fall 2018.

Similar presentations


Presentation on theme: "Git CS 110 - Fall 2018."— Presentation transcript:

1 Git CS Fall 2018

2 It’s never final

3 The Command Line The command line or command-line interface, is a text-based version of your Operating System. Like Windows Explorer or Finder on the Mac, without the graphical interface. Other names for the command line are: cmd, CLI, prompt, console or terminal. The blinking cursor is called the ‘prompt’

4 Commands There are hundreds of different commands you can use on the command line whoami pwd ls Some commands take parameters cd <folder>

5 Linux Directory Structure
Directories are organized as a tree You are always in some directory many commands are relative to your current directory mkdir creates a new directory in your current working directory Windows commands are different from Mac and Linux

6 Managing Your Code Many of the concepts we learn in CS are an attempt to manage large projects and reduce complexity Functions, OOP, Data Structures, Design Patterns, etc. Large Project Problems: Managing large projects that go on for years with multiple people? Adding a feature without breaking the current version? What if someone’s code breaks the project? How do we revert?

7 Managing Your Code What we need:
We need a way to maintain previous versions of our code. We’ll also need to restore previous versions We also need a way to keep everyone’s code synchronized, but only at fixed points. Finally, we need to have different versions of our code that so current development doesn’t break working, previous versions of the project.

8 Possible Solutions Use a Local Repository
A repository, or repo, holds all the previous versions of your code. If you make a new copy of your code and save the old version in a folder called “backup” every time you make significant changes, the folder called backup is your repository. Pros: Simple, allows restore Cons: This doesn’t help with team projects Quickly grows in size

9 Possible Solutions Use a Centralized, Networked Repository
Previous versions are on a server that all developers can access Any change made by developers must be added to the one central repository. Developers keep only the latest versions on their computer Pros: Less memory required on your machine Easier to synchronize with team Cons: Not all code is good, and somebody needs to be the gatekeeper. Consider an active project like VLC with hundreds of contributors trying to add dozens of small changes every day. How do you maintain quality?

10 Git A better solution is to allow developers to check in with everyone for updates when they want or are able to. Git was designed as a Distributed Version Control System (DVCS). That means that projects using Git would need developers to have a local repository stored on their system.

11 Git Each developer is free to test any changes made on her own local instance of the repository before committing changes Called Integration Testing and Acceptance Testing You pull in other developer's changes only when you want to.

12 Doesn’t that use more memory?
Git only stores changed files in new versions. If a file has not changed in a version, it will be linked, not copied. Git compresses all files stored in the repository Text files compress up to 60%, and most files in a programming projects are just text files Memory is cheap cheap: a lot of it expensive: limited resource

13 Branching Git also introduces Branching

14 Branching Branching allows developers to try something out, and decide later if they want to integrate it Merge a branch with the main project at any time You can also merge a branch with another branch This allows you to try out new features without messing with the main repository

15 Sample Git Project

16 The Stages of Git - The Working Directory
To initialize a git repo git init new repo git clone copy of an existing repo The working directory is the actual project in its most current state i.e. the source files you are currently working on

17 The Stages of Git - The Staging Area
List of files ready to be placed into the next snapshot Think of this as the loading dock for your next commit To add a file git add <filename>

18 The Stages of Git - The Commit
The Commit is the snapshot of the project in some particular state commit creates a restore point that you can use to revert to or branch from Includes snapshot, author, date, committer (can differ from author), parent commit To create a commit: git commit -am “Message stating what has changed”

19 The Stages of Git - The Remote
A copy of more or less the same repo The remote can be any networked computer You can access the other machine with the following: git pull <machine name> <branch> git push <machine name> <branch>

20 Problems with Git and the Github solution
Git never told us who to trust Anyone can make changes, and you may accidentally pull them Git repositories are open to all passwords saved in a file are visible to anyone GitHub is a web-based open Git repository. Brings back some centralization to git Github introduces authentication and a web interface We often call Github “the origin”

21 Adding Github to your workflow
To add a Github repository, you need to sign up for an account It’s free and open to everyone! You must then add the Github repo as a remote to your project git remote add origin <remote repository URL> usually the github repo is called origin, but can be named anything you like

22 Git Universe Summary Git Github
A distributed version control that allows you to maintain a repo on your system, but send and receive changes from others when they are ready Github A web service that can act as a central repository for a git repo Adds some security to a git repo, while still allowing anyone to branch

23 Git - Limitations Git trusts everyone to know what they are doing
Anyone with permission can commit or alter the repository It’s your job to know you shouldn’t pull those changes Anyone can make any changes they want Git commands are complex and confusing I still have to look up the commands constantly Documentation of the commands is pretty terrible git-rebase – Reapply commits on top of another base tip move a branch to include another branches changes

24 Starting a Github Repo - Example
Standard git repo procedure git init git add <filename> git commit -am “My commit message” Working with remotes git remote add origin git push origin master git pull origin master

25 Cloning a github repo You can clone any public github (or git based) repository git clone downloads the entire repo to your machine git push pushes updates (as long as you have proper authentication) git pull pulls latest updates


Download ppt "Git CS 110 - Fall 2018."

Similar presentations


Ads by Google