December 6th 1pm - December 7th 5pm Sendgrid - Boulder
December 9th. 5:30-7:30pm Dojo 4 - Boulder
Miles
- Senior developer at dojo4.com - 17th & pearl st behind Ted's. Stop by anytime!
- miles.matthias@gmail.com
Evan
- Full-stack dev in training at gSchool
- etmoore@gmail.com
- Make a directory
$ mkdir <dir name>
- Move into the repository
$ cd <dir name>
- Initalize a git repository
$ git init
$ git init
- Create a new, local repository
$ git status
- Check the status of your current repository and see which files have changed.
$ git diff
- See the differences between your working tree and the latest commit.
$ git log
- Show all commits for the current branch, starting with the newest.
$ git log --oneline --decorate --color --graph --all
- View the full tree history with an awesome commit graph, use instead.
$ git add <filename>
- Add a file and its changes to the staging area.
$ git add -A
- Add all files and changes to the staging area.
$ git commit -m "<commit message>"
- commit staged changes (the -m
flag will let you add your commit message inline).
$ git branch <branch name>
- create a new branch
$ git branch
- list all branches
$ git checkout <branch name>
- switch to a different branch.
$ git merge <branch name>
- merge target branch into current branch.
- Do some work
$ git status
to review your changes.$ git add <filename>
to add files to the staging area. (Use$ git add -A
to add all files and changes.)$ git status
to see what you're about to commit$ git commit -m "<message>"
to commit the changes in the staging area with a message.
- Create a new directory 'song-lyrics'.
cd
into that directory. - Initialize a git repository.
- Create a new text file with the name of your favorite song. Example:
touch blank-space.txt
- Check the status of your repo to confirm that your new file exists and has not yet been added to your repo.
- Add the new file to your staging area.
- Commit the new file to you repo with the message "added [filename].txt to the repo"
- Open the file in your text editor and write two lines of the song lyrics.
- Check the status of your repo to see your changes.
- Add your changes to the staging area.
- Check the status to confirm that your changes have been added to the staging area.
- Commit the changes to your repository with the message "first two lines"
- Repeat steps 7-10, adding the third and fourth line of the song to what you already have written. Commit these changes with the message "third and fourth lines".
- Repeat steps 7-10 one more time, adding the fifth and sixth lines. Commit changes with the message "fifth and sixth lines".
- Run the fancy git log command (
git log --oneline --graph --decorate --all
) to see your commit history. You should see 4 commits. Congrats! You've completed the first exercise.
$ git clone <repo path or URL>
- clone a repository into a new directory.
$ git remote
- List all remotes for the current repo.
$ git remote add <remote name> <remote path or URL>
- adds a remote to your repo.
$ git pull <remote name> <branch name>
- Pull down changes from a remote and integrate them into your repo. Performs git fetch
and then git merge
.
$ git push <remote name> <branch name>
- Send your changes to the remote to be merged.
- Log into your GitHub account
- Create a repository on GitHub called 'song-lyrics'. (Don't initialize a readme). Copy the repo URL to your clipboard.
- On your command line: Add the github 'song-lyrics' repo as a remote for your local 'song-lyrics' repo. Give the github repo the name
origin
. - Push your local commits up to github.
- Go back to the GitHub song-lyrics repo (in your browser) and confirm that your commits were pushed... Congrats! You've made your first push to GitHub! Now your code is visible to the world.
- In your text editor, write the first two lines if your song's chorus.
- Check your repo's status, add, then commit the changes with the message "first two lines of chorus".
- Push your changes up to Github. Confirm that the latest commit is there by looking at the commit history on GitHub.
- In your text editor, finish writing the chorus.
- Check the status of your repo, add, then commit the changes locally.
- Push the changes up to GitHub.
Finished early? ...
- Create a new file in your song-lyrics directory with the title of your second favorite song.
- Add the file to be tracked by git.
- Open the file in your text editor and make some changes.
- Add, then commit the changes with a message of your choice. At this point, the file exists locally but does not exist in your remote repository. Confirm this by looking at your GitHub song-lyrics repo page.
- Push your commits up to GitHub. You should now see the new file in your remote repo. Cool, eh?
- Partner with 2 of your classmates to make a team of 3.
- Decide who will be partner #1, #2, and #3.
Everyone:
- Move out of your song-lyrics directory and create a new directory called 'gdi-haiku'.
cd
into the 'gdi-haiku' directory and initialize a git repo.- Create a new file
<your first name>-haiku.txt
- Add the file to be tracked and commit with the message 'created haiku file'.
- Open the .txt file in your text editor and write the first line of the haiku. (Make it up! 5 syllables!)
- Add, then commit your changes with the message "first line of haiku by [your first name]"
- On GitHub, create a repo called 'gdi-haiku'.
- Add the new GitHub repo as a remote called
origin
. - Push your local commits up to GitHub.
- Confirm that your commits are now on GitHub.
STOP! Make sure your teammates have caught up before moving on to part 2.
- Partner #1, go to partner #2's gdi-haiku GitHub repo and fork it. Partner #2, do this to partner #3's repo. Partner #3, do it to Partner #1's repo.
- Clone the new forked repo (the url should have your username in it) to your computer.
- Open your partner's haiku.txt file and write line 2 of the haiku. (Make it up! 7 syllables!)
- Add, then commit the change to your local repo.
- Push the change up to GitHub. Your change should now be reflected in your forked repo.
- Click the green pull-request button. Review the changes. Click "Create Pull Request".
- Give your pull request a title and (optional) comment. Click "Create Pull Request" to submit a pull-request to you partner.
Congrats! You've submitted your first pull-request!
STOP! Make sure your teammates have caught up before moving on to part 3.
- Go to your gdi-haiku GitHub repo. You should see a pending pull-request from your partner. Review the pull-request and accept it if it looks good to you.
Congrats! You've accepted your first pull-request!
STOP! Make sure your teammates have caught up before moving on to part 4.
- Repeat the steps in Part 2 and Part 3, but this time on your other partner's repo. Instead of writing the 2nd line of the haiku, you should be writing the 3rd and final line.
- When finished, all three partners should a complete haiku, authored with two collaborators.
Nicely done!
Aliases - Make git commands easier and faster to type with command line shortcuts. For more: http://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
Rebasing - Another way to merge that keeps your git history cleaner and more streamlined. For more: http://git-scm.com/book/en/v2/Git-Branching-Rebasing
Pro Git (free e-book) - http://git-scm.com/book
Try git - https://try.github.io
Github Training Videos - https://www.youtube.com/user/GitHubGuides
Git for Ages 4 and Up (Video) - https://www.youtube.com/watch?v=1ffBJ4sVUb4
A Practical Git Introduction - http://mrchlblng.me/2014/09/practical-git-introduction/
Git Branching Game - http://pcottle.github.io/learnGitBranching/
Github Guides - https://guides.github.com/