Git / Github + TReddit
Git Vocab:
Version Control: Basically, the purpose Git was designed to serve. When you have a Microsoft Word file, you either overwrite every saved file with a new save, or you save multiple versions. With Git, you don’t have to. It keeps “snapshots” of every point in time in the project’s history, so you can never lose or overwrite it.
Repository: A directory or storage space where your projects can live. Sometimes GitHub users shorten this to “repo.” It can be local to a folder on your computer, or it can be a storage space on GitHub or another online host. You can keep code files, text files, image files, you name it, inside a repository.
Git Vocab:
Commit: This is the command that gives Git its power. When you commit, you are taking a “snapshot” of your repository at that point in time, giving you a checkpoint to which you can reevaluate or restore your project to any previous state.
Branch: How do multiple people work on a project at the same time without Git getting them confused? Usually, they “branch off” of the main project with their own versions full of changes they themselves have made. After they’re done, it’s time to “merge” that branch back with the “master,” the main directory of the project.
Git Commands:
Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.
$ git init
Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.
$ git status
Git Commands:
This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.
$ git add
Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.”The -mindicates that the following section of the command should be read as a message.
$ git commit
Git Commands:
Working with multiple collaborators and want to make changes on your own? This command will let you build a new branch, or timeline of commits, of changes and file additions that are completely your own. Your title goes after the command. If you wanted a new branch called “cats,” you’d type git branch cats.
$ git branch
Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check.
$ git checkout
Git Commands:
When you’re done working on a branch, you can merge your changes back to the master branch, which is visible to all collaborators. git merge cats would take all the changes you made to the “cats” branch and add them to the master.
$ git merge
Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check.
$ git checkout
Git Commands:
If you’re working on your local computer, and want your commits to be visible online on GitHub as well, you “push” the changes up to GitHub with this command.
$ git push
$ git pull
If you’re working on your local computer and want the most up-to-date version of your repository to work with, you “pull” the changes down from GitHub with this command.
Git Workflow:
Team Project:
TReddit
We've walked you step by step through about 4 projects now. Let's see what you can do on your own!
If you're not familiar with Reddit check out www.reddit.com.
Essentially it's a site where users can post a link which then gets up-voted or down-voted by other users. There is also a commenting feature. Sound familiar? Kind of like a blog?
TTS Dev Shop
We're going to use Github to pair program today. Let's break into teams choose a team leader. Ready? Go!
Changing Team Name:
Matthew
Mark
Divine Elegance:
Ben
Jennifer
Tech Moms
Anita
Danielle
Team Donkey Kong:
Thomas
Cameron
Getting Started
Team leaders, let's set you up on GitHub.
$ rails new treddit
$ cd treddit
$ git init
$ git add .
$ git commit -m 'first commit'
$ git remote add origin https://github.com/[username]/treddit.git
$ git push -u origin master
Now hit your treddit link on GitHub and click settings, then collaborators and add your partner to the project.
ATL: GitHub + TeamWork
By tts-jaime
ATL: GitHub + TeamWork
- 1,063