A primer on working smarter and enabling collaboration through a VCS
By Alex LaFroscia
Note: If you think about it, we do stupid things all the time
- "Fixed" some code, messed it up, and need to undo everything
- Deleted an important file and can't recover it
- Moved some code while refactoring and can't remember what it was
- Commented out code to remember it because you'll need it eventually
- Wrote something a long time ago and forgot why
Note: All of these thing suck, or make our code messy
- Save snapshots of your project
- Restore to any given snapshot
Note: These two simple actions enable us to avoid all of the problems that we just looked at
- Easy rewind to the last working version
- Recover a file from a previous snapshot
- View previous snapshots to reference old versions
- Leave yourself notes and details outside of the code itself
- Wikipedia lists over 40 types of VCSs, Git is just one
- Git has been made popular in part thanks to Github and open-source code
- You don't have to use Git, but please use something!
Note: Many version control system have well-defined ways for sharing code between multiple developers. Basically, this allows you to sync the snapshots that you have on your computer with those that other people have to make sure that everyone has the same code
- Store code online
- Enables easy collaboration
- Find open source projects
- Tons of code available for use and learning, for free
- Big companies publish their code for other people to benefit from
- Anyone can contribute to any open source code
7:00pm, Sennott Square Rm. 5317
- Get Git installed and set up on our computers
- Understand and use the basic commands of Git
- Walk through the workflow of collaboration through Github
- Go over some Git vocabulary and commands
- Install Git, make Github accounts and set up authentication
- Practice using Git, including working with a shared repository
- A project being organized by Git
- High level: A "snapshot" of your project
- Low level: A record of changes since the last commit
- Each has a unique identifier, called a hash
- Contains information about what was added
- A collection of commits
- master is the main branch
- branch off from master and merge back in
- A server that stores a copy of your repository
- Used to save your work off-site and enable collaboration
- You push to a server and pull from a server
Check the current status of your project
$ git status
On branch workshop-slides
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: slides.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
test-file.txt
Stage a set of changes to be part of the next commit
$ git add test-file.txt // Stage one file
$ git add -A // Stage all of the current changes
Make a new commit
$ git commit // Will open your editor to write message
$ git commit -m 'My commit message!' // Make commit with messge
Push to and pull from a remote
$ git push origin master
$ git pull origin master
If there are any questions or problems, come see me!