now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this...
TRANSCRIPT
![Page 1: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/1.jpg)
now you git it! (part ii)PICSciE bootcamp 2019by dev dabke ([email protected])
![Page 2: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/2.jpg)
me
● he/him/his● education
○ applied math phd @ Princeton○ math/cs undergrad @ Duke
● industry○ AG350, Inc., other ventures○ ex-BlackRock, Airtable
● started with svn, then realized how git works and why it’s awesome
![Page 3: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/3.jpg)
1. introduction
![Page 4: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/4.jpg)
citation: xkcd and https://github.com/qw3rtman/git-fire
![Page 5: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/5.jpg)
workshop structure
1. overall stylea. feel free to jump in with questions at any time (don’t be afraid!)b. i will poll the audience a lot
2. today: a little theory and then mostly practical knowledgea. discuss some more advanced git conceptsb. practical examples as an individualc. working session as a teamd. more advanced tooling
3. high-levela. day 1: local, personal workflow; introduction to theoryb. day 2: remote, team workflow; more practical
![Page 6: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/6.jpg)
errata
1. git branch is a legitimate way to create branchesa. however: this only creates a branch, but does not immediately checkout to itb. usage: run git branch branch-name and then git checkout branch-name
2. git push --force should be avoided on shared resourcesa. sometimes useful if you’re the only one working on a branchb. necessary after a rebasec. be very careful with this
![Page 7: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/7.jpg)
centralized vs. decentralized
decentralized● everyone has the entire repo (yes,
submodules exist in git, etc., but c’mon)● checkout / checkin from anywhere● “canonical code” is established by
convention (`master` or `origin` aren’t special names in git)
centralized● one “master” repo● central server or machine hosts the
“canonical code”● checkout / checkin to one place● checkout only parts of a repo● easy to manage permissions
![Page 8: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/8.jpg)
mutable● possible to change history● history can be beautified, changed to be
easier to read for the future● more flexible● can be more dangerous
immutable vs. mutable
immutable● cannot rewrite the “history” or “record” of
what has happened● history reflects what actually happened● safer
![Page 9: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/9.jpg)
isn’t github a centralized system, though? wait . . . what is github?
![Page 10: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/10.jpg)
(aside: this is why we don’t use gitlab, although it is open-source)
![Page 11: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/11.jpg)
what is a commit?
![Page 12: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/12.jpg)
what is a branch?
![Page 13: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/13.jpg)
how do we reconcile differences between commits?
![Page 14: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/14.jpg)
recap
1. git is decentralized, mutable2. github (or equivalent) is a hosting service3. everything in git is an object, which has
a. contentb. pointer
4. branches are labels
![Page 15: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/15.jpg)
pop quiz: what is special about master?
![Page 16: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/16.jpg)
2. introduction
![Page 17: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/17.jpg)
repository
1. a folder that has been initialized by git2. contains
a. a working directory, i.e. what your filesystem seesb. a .git folder that maintains the version control information
![Page 18: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/18.jpg)
remote
1. location (or address) of a git repository2. can be on
a. your computerb. a local networkc. over the internet with
i. sshii. http(s)
3. composed ofa. a urlb. a name
![Page 19: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/19.jpg)
ref
1. unique way to identify a resource2. composed of a
a. remoteb. object identifier
![Page 20: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/20.jpg)
ref: HEAD
1. what current working directory is pointing at2. what is actually being changed upon checkout
![Page 21: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/21.jpg)
2. individual work
![Page 22: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/22.jpg)
preamble
1. setup a github accounta. associate and verify a personal email addressb. turn on two-factorc. associate and verify your princeton email if you have one; activate education account
2. ssh keysa. if you don’t have them:
https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
b. once you’ve created them or if you already have them: https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account
![Page 23: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/23.jpg)
repository creation
1. create a new (public) repository on github2. initialize it with a readme file
![Page 24: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/24.jpg)
git clone
setup a local replica repository from a remote
![Page 25: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/25.jpg)
pop quiz: what is special about origin?
![Page 26: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/26.jpg)
git push
push a commit to a remote
![Page 27: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/27.jpg)
git fetch
check for changes in your local repository against a remote
![Page 28: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/28.jpg)
git pull
performs a fetch and merge at the same time (avoid this)
![Page 29: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/29.jpg)
local first, then remote
1. create a local repository2. then, create one on github
a. decline all automated configurations
3. push up your local repository
![Page 30: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/30.jpg)
3. team workflow
![Page 31: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/31.jpg)
preamble
1. pair up2. for each exercise
a. one person should create a repository with no default initializationb. add your teammate to your repositoryc. your teammate can now clone the repository
![Page 32: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/32.jpg)
general working principles
1. branches are cheapa. create personal working branchesb. even for collaborative work, create focused “feature” branchesc. be fearless: branch off of branches
2. keep master clean (so there is always one working version)3. stay in-sync with master
a. if ready, mergeb. otherwise rebase
4. first person to master winsa. the person merging into master is responsible for reconciling conflicts
5. fetch before you push
![Page 33: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/33.jpg)
ex. 1
1. create a README with each person’s namea. one person create README and commit to masterb. each person add a commit to their local master branch with their namec. reconcile the differences
![Page 34: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/34.jpg)
ex. 2
1. create a README with each person’s name2. each of you create your own file
a. use your own feature branchb. merge into master
![Page 35: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/35.jpg)
ex. 3
1. create a README with each person’s name2. each of you create your own file on your own feature branch3. collaborate on the feature branch
a. push up your feature branchb. the other person should modify your file on your feature branchc. pull in their changesd. merge the branch into master
![Page 36: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/36.jpg)
ex. 4
1. create a README with each person’s name2. each of you create your own file on your own feature branch3. initiate a pull request
a. push up your feature branchb. on github, click on pull request (pr) to masterc. once accepted, merge in through the UI
![Page 37: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/37.jpg)
ex. 5
1. create a README with each person’s name2. each of you create your own file on your own feature branch3. create secondary feature branches
a. other person shouldi. checkout and branch off of your feature branch
ii. make changes in their secondary feature branchiii. submit a “pr” to your feature branch
b. you should accept their prc. other person should merge their pr into your feature branch
4. finalize the feature brancha. make changes and submit a pr to masterb. merge in through command line
![Page 38: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/38.jpg)
fork
1. github concept2. replica of a repository but not integrated via git3. a way to handle permissions, since anyone with access to a repo can access the
whole thing
![Page 39: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/39.jpg)
ex. 6: massive fork experiment
1. fork my repository2. submit a pr by editing the README3. merge in changes
![Page 40: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/40.jpg)
wrap up
1. git is nota. a substitute for project managementb. a tool for communication
2. many ways to use git3. be courteous to your collaborators, strict with yourself
![Page 41: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/41.jpg)
4. advanced workflows
![Page 42: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/42.jpg)
project setup
1. gitignore2. README3. permissions
![Page 43: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/43.jpg)
hooks
1. scripts that active on events
![Page 44: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/44.jpg)
integrations
1. ci/cd2. communication3. project management
![Page 45: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/45.jpg)
1. “continuous integration, continuous delivery”a. ambitious b. broad
2. circlecia. integrate checks to githubb. “verifies” code
3. othersa. styleb. test coveragec. more?
ci/cd
![Page 46: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/46.jpg)
1. slack2. more?
communication
![Page 47: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/47.jpg)
1. github itself2. more?
project management
![Page 49: now you git it! (part ii) · 1. git branch is a legitimate way to create branches a. however: this only creates a branch, but does not immediately checkout to it b. usage: run git](https://reader033.vdocument.in/reader033/viewer/2022051804/5feccc766553fe3742143b7b/html5/thumbnails/49.jpg)
now you git it!