Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
now you git it! (part ii)PICSciE bootcamp 2019by dev dabke ([email protected])
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
1. introduction
citation: xkcd and https://github.com/qw3rtman/git-fire
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
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
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
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
isn’t github a centralized system, though? wait . . . what is github?
(aside: this is why we don’t use gitlab, although it is open-source)
what is a commit?
what is a branch?
how do we reconcile differences between commits?
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
pop quiz: what is special about master?
2. introduction
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
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
ref
1. unique way to identify a resource2. composed of a
a. remoteb. object identifier
ref: HEAD
1. what current working directory is pointing at2. what is actually being changed upon checkout
2. individual work
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
repository creation
1. create a new (public) repository on github2. initialize it with a readme file
git clone
setup a local replica repository from a remote
pop quiz: what is special about origin?
git push
push a commit to a remote
git fetch
check for changes in your local repository against a remote
git pull
performs a fetch and merge at the same time (avoid this)
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
3. team workflow
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
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
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
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
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
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
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
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
ex. 6: massive fork experiment
1. fork my repository2. submit a pr by editing the README3. merge in changes
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
4. advanced workflows
project setup
1. gitignore2. README3. permissions
hooks
1. scripts that active on events
integrations
1. ci/cd2. communication3. project management
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
1. slack2. more?
communication
1. github itself2. more?
project management
now you git it!