Powerful Google developer tools for immediate impact! (2023-24 C)
Git & GitHub WorkShop
1. Git and the world of
collaborative projects
Zhixing Che
Boston University DSC
Boston University Developer Student Club
2. What is Git and Github?
● Git is a version control system (VCS)
○ easier to have multiple versions of code base sometimes across multiple developers
● Github is a website that hosts git repositories on a remote server
○ if git are movies, Github is like Netflix
○ the most popular git repository website, many developers’ portfolio of
choice
4. Let’s try it out!
● Check that git is installed and that you have a github account
○ run `$ git` in terminal
○ if you don’t have it yet, you can find installation guide on git’s website
● Configure git if it is your first time using it
○ `$ git config --global user.name “firstname lastname”`
○ `$ git config --global user.name “email@email.com”`
5. Connect to repository hosted on Github
● Create a repository on your personal page on github
○ several options to set up your local repo for that project
■ SSH
■ HTTPS
■ Terminal commands (more on it later)
● SSH sidenote
○ It is common and recommended to configure git and github to recognize Secured
Shell (SSH) keys that you generate, so you don’t need to enter github password each
time
○ you can check so by going to https://github.com/settings/keys
6.
7. Git / Github Workflow
● Open pull request on Github for preparation for merging
● Stage commits for files to be added into the repository
○ `$ git add <filename> `
○ `$ git add . `
● Commit changes and leave description
○ `$ git commit -m <message> `
● Push changes to save them
○ `$ git push origin <branch name> `
8. Git / Github Workflow
● Create a new branch of a project for testing out new functionalities/versions
● Resolve merge conflicts before merging
○ will be automatically checked by Github
● Merge
○ 3 types of merging
9. Git Branching
● View current branches
○ `$ git branch`
● Create a new branch
○ `$ git checkout -b <branch name>`
● Switch to existing branch
○ `$ git checkout <branch name>`
10. Merge, Squash & Merge, Rebase & Merge
● Merge vs Rebase (feature here just refers to a topic branch)
○ merge is generally easier, can done from command line
■ `git checkout feature` then `git merge feature master`
■ non-destructive operation that ties the histories of both branches. This
preserves the exact history of your project
■ may lead to muddling of the history of branch since it essentially creates
a forked history
○ rebase
■ `git checkout feature` then `git merge feature master`
■ move the entire feature branch to start from the tip of the master branch
by rewriting the project history and creating brand new commits for each
commit in the original branch.
■ singular history with no forking of commit history
■ may lose context
11. Lots of cool stuff on Github!
● Explore projects and fork them!
○ fork creates a copy of another repo
● Nice GUI
○ compare branches
○ make wiki for project
○ also capability to utilize github desktop and do things on GUI
■ https://guides.github.com/activities/hello-world/
■ though, command line knowledge is important for cs in college and
beyond :)