git and github - cs50 and github.pdf · git add -a signals to git that it should track all existing...
TRANSCRIPT
![Page 1: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/1.jpg)
Git and GitHub
![Page 2: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/2.jpg)
● Version Control System○ Keep careful track of changes in your files○ Collaborate with others on your projects more easily○ Test changes without losing the original versions○ Revert back to older versions when/if needed
● GitHub: web-based hosting service for git○ Provides a "remote" location for storing your git workspaces○ Useful if you lose/break your computer, etc.
What is Git?
![Page 3: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/3.jpg)
● Installation○ https://github.com/join○ https://help.github.com/articles/set-up-git/
● How it works○ Create a "repository" (workspace) for your project ○ Add/remove/save/edit files ○ Push local files online to GitHub / pull remote files from GitHub to your
local workspace○ And more!
Using Git
![Page 4: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/4.jpg)
● Downloads an existing repository from GitHub ● Creates a synced, local copy
git clone <url>
![Page 5: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/5.jpg)
![Page 6: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/6.jpg)
![Page 7: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/7.jpg)
![Page 8: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/8.jpg)
● Signals to git that the specified file should be “tracked” for changes○ Places modified file(s) in the “staging area”
● Files not added in this way are essentially ignored by git● git add -A signals to git that it should track all existing files
git add <filename>
![Page 9: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/9.jpg)
![Page 10: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/10.jpg)
![Page 11: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/11.jpg)
![Page 12: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/12.jpg)
![Page 13: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/13.jpg)
● Takes a "snapshot" of all files currently on the staging area and commits it to git's memory
● The "snapshot" is captioned with the given message as a brief description for the commit
git commit -m "message"
![Page 14: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/14.jpg)
![Page 15: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/15.jpg)
![Page 16: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/16.jpg)
![Page 17: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/17.jpg)
● Nearly identical to previous command, with the added step of applying git add to all existing tracked files first○ Ignores untracked files
git commit -am "message"
![Page 18: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/18.jpg)
● Displays useful information about your repository (e.g., current branch, tracked/untracked files, differences between local and remote versions)
git status
![Page 19: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/19.jpg)
![Page 20: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/20.jpg)
![Page 21: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/21.jpg)
![Page 22: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/22.jpg)
● Uploads local commits to the remote repository (i.e., from your computer to GitHub)
git push
![Page 23: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/23.jpg)
![Page 24: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/24.jpg)
![Page 25: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/25.jpg)
![Page 26: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/26.jpg)
● Downloads remote commits to the local repository (i.e., from GitHub to your computer)
git pull
![Page 27: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/27.jpg)
![Page 28: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/28.jpg)
![Page 29: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/29.jpg)
![Page 30: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/30.jpg)
● When two collaborators make conflicting changes to the same file, a merge conflict may arise
● Git will complain when you attempt to git pull and you will need to manually resolve the conflict
Merge Conflicts
![Page 31: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/31.jpg)
![Page 32: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/32.jpg)
![Page 33: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/33.jpg)
![Page 34: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/34.jpg)
![Page 35: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/35.jpg)
![Page 36: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/36.jpg)
![Page 37: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/37.jpg)
![Page 38: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/38.jpg)
![Page 39: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/39.jpg)
● Displays history of commits made in the repository from newest to oldest
git log
![Page 40: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/40.jpg)
![Page 41: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/41.jpg)
![Page 42: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/42.jpg)
![Page 43: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/43.jpg)
● Each repository by default has a "master" branch where all your work lives
● Sometimes useful to create separate branches in your repository (to test new features, separate work among collaborators, etc.)
Branching
![Page 44: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/44.jpg)
![Page 45: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/45.jpg)
![Page 46: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/46.jpg)
![Page 47: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/47.jpg)
![Page 48: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/48.jpg)
![Page 49: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/49.jpg)
![Page 50: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/50.jpg)
![Page 51: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/51.jpg)
![Page 52: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/52.jpg)
![Page 53: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/53.jpg)
![Page 54: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/54.jpg)
![Page 55: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/55.jpg)
● By default, lists all of the branches in your repository, but has a few other variations:
● git branch <branch>○ Creates a new branch with the given name
● git branch -d <branch>○ Deletes the specified branch
git branch
![Page 56: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/56.jpg)
● Switches from the current branch to the specified branch (must already exist)
git checkout <branch>
![Page 57: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/57.jpg)
● First creates a new branch with the given name, then switches to it
git checkout -b <branch>
![Page 58: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/58.jpg)
● Merges the specified branch to the current branch
git merge <branch>
![Page 59: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/59.jpg)
● GitHub is a popular home for "open source" projects (i.e., projects whose source code is freely available online and may be redistributed and modified).
Open Source
![Page 60: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/60.jpg)
● Create a copy of someone else’s repository on your profile so that you can contribute to their project
Forking
![Page 61: Git and GitHub - CS50 and GitHub.pdf · git add -A signals to git that it should track all existing files git add Takes a "snapshot" of all files currently on the](https://reader034.vdocuments.site/reader034/viewer/2022052611/5f06eeaa7e708231d41a7473/html5/thumbnails/61.jpg)
Final questions?