session 2: git basics cs3110 level up! - cornell university · 2019-08-18 · git: version control...
TRANSCRIPT
![Page 1: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/1.jpg)
CS3110 Level Up!Session 2: Git BasicsAnna Fang
![Page 2: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/2.jpg)
Git:Version control systema.k.a. allows users to collaboratively work on code
![Page 3: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/3.jpg)
A few things to start:
local: code on your machine (i.e. your version of the codebase, your changes that you made)
remote: code not on your machine (i.e. the production codebase in Github)
repository: a project/set of files
working directory: the folder you’re working out of (i.e. /home/Desktop/myRepository)
staging area: a place for files getting ready to be pushed out (like a loading dock)
![Page 4: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/4.jpg)
git pull
![Page 5: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/5.jpg)
git pull:
- fetch and pull files from a remote repository
- updates files in local respository
![Page 6: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/6.jpg)
git add
![Page 7: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/7.jpg)
git add . or git add <filename>:
- add file and its changes to the staging area- files that you change are not automatically staged
![Page 8: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/8.jpg)
git commit
![Page 9: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/9.jpg)
git commit -m “<new message>”:
- collect the files in the staging area
- records the changes to the repository like a snapshot
![Page 10: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/10.jpg)
![Page 11: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/11.jpg)
git push
![Page 12: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/12.jpg)
git push:
- upload local repository content to remote repository
- i.e. I’ve made changes and I want my partner to see them now!
![Page 13: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/13.jpg)
git reset
![Page 14: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/14.jpg)
git reset <filename>:
- Unstage file(s)
- i.e. I’ve done “git add” on file(s) that I don’t actually want to stage!
![Page 15: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/15.jpg)
git reset HEAD~1:
- Remove the commit before
- git reset HEAD~num removes num commits before
![Page 16: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/16.jpg)
git revert
![Page 17: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/17.jpg)
git revert <commit ID>:
- Undo the commit from commit ID, as if it didn’t happen, but keep a record of it.
- This creates a commit
- i.e. I messed up, but don’t want to just delete the commit from the history. Instead, I want the log to show that I undid a commit.
![Page 18: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/18.jpg)
git checkout <file>
![Page 19: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/19.jpg)
git checkout <filename>:
- Change a file to the version on the remote repository
- i.e. I want the version of a file on the remote repository. You can think of this as an “undo” operation on your changes.
- Note: git checkout has different meanings depending on if you give it a filename, branch, commit, etc. We are only talking about filename for right now.
![Page 20: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/20.jpg)
git status
![Page 21: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/21.jpg)
git status:
- Shows state of the working directory and staging area
![Page 22: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/22.jpg)
git log
![Page 23: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/23.jpg)
git log:
- Shows your commit history
![Page 24: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/24.jpg)
![Page 25: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/25.jpg)
Demo
![Page 26: Session 2: Git Basics CS3110 Level Up! - Cornell University · 2019-08-18 · Git: Version control system a.k.a. allows users to collaboratively work on code. A few things to start:](https://reader034.vdocument.in/reader034/viewer/2022052612/5f0c0c507e708231d4337d9d/html5/thumbnails/26.jpg)
Next week: Advanced GitMerging, branching, cherry picking, rebasing, etc