Presentation is loading. Please wait.

Presentation is loading. Please wait.

Version Control with Git and GitHub

Similar presentations


Presentation on theme: "Version Control with Git and GitHub"— Presentation transcript:

1 Version Control with Git and GitHub

2 Lets look at the course website

3 Why use version control?
Enables collaboration Merge changes to the same file View how code changes over time Visualize history of a code file Revert to specific version Recent change breaking things? Undo! See who is contributing Find all changes by username Backup Master copy is kept elsewhere (hopefully) Great for solo projects too!

4 Basics of Version Control

5 Basics of Version Control
Each user has a working copy Changes must get committed to the server Might require a merge

6 Types of Version Control
Older VCS were “centralized” CVS SVN Distributed version control! Git Mercurial with GitHub for hosting and services

7 Distributed Version Control

8 GitHub-User Perspective
You GitHub Working Dir Local Repos Remote Repos

9 First: Lets set up Git git config --global user.name “Austin Henley”
git config --global user. git clone git config credential.helper store git pull Warning: stores pw in plaintext locally Alternative: setup Git to use SSH

10 Optional: If you don’t like VI
If VS Code is installed and in your PATH Test by doing: code –help git config --global core.editor “code --wait” git config --global -e

11 Try it!

12 Working with Git working directory staging area gets repo from GitHub
local repository clone remote repository

13 Working with Git working directory add stages files you changed
staging area local repository remote repository

14 Working with Git working directory staging area commit saves changes
local repository remote repository

15 Working with Git working directory sends all your commits to GitHub
staging area local repository push remote repository

16 Working with Git working directory staging area
gets latest version from GitHub local repository pull remote repository

17 Handy commands Get the repo for the first time
git clone See the status of your local repo git status Stage a file you modified git add filename Stage all modified files git add -A Commit staged changes git commit -m ”Foobar” Push your commits to GitHub git push

18 Try it!

19 Get previous versions See commits to a file
git log filename Get previous version of repo git checkout commitid . Get previous version of file git checkout commitid -- filename Go back specific number of commits (e.g., 5) Git checkout master~5 -- filename Return to latest version git checkout master

20 I made a mistake! How do I…
Unstage a file? git reset HEAD filename Uncommit? git reset --soft HEAD^ Undo your changes and go back to a fresh repo? git reset --hard HEAD^ Careful!!!

21 How to organize a commit?
Commits should be logical groupings of code changes E.g., all the changes to fix a bug Try to make commits small and frequent Not fun to look through 2000 lines of changes across 11 files 

22 A Few Resources A tutorial A visual explanation of Git
A visual explanation of Git Git cheat sheet for commands

23 Lets walk through GitHub


Download ppt "Version Control with Git and GitHub"

Similar presentations


Ads by Google