Top Banner
Today's Goals 1.Install Git. 2.Get a Github Account 3.Download a Repo 4.Fork a Repo 5.Create a Branch 6.Create a Pull Request 7.Create your own repo
61
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Git for Artists

Today's Goals1.Install Git.

2.Get a Github Account

3.Download a Repo

4.Fork a Repo

5.Create a Branch

6.Create a Pull Request

7.Create your own repo

Page 2: Introduction to Git for Artists

Today's Secondary Goals1.Know what Git is.

2.Know why you should care.

Page 3: Introduction to Git for Artists

What is Git?

Page 4: Introduction to Git for Artists

A better way to download open source software.

git clone https://github.com/jquery/jquery.git

Page 5: Introduction to Git for Artists

No, What is Git?

Page 6: Introduction to Git for Artists
Page 7: Introduction to Git for Artists

What is version control?

Page 8: Introduction to Git for Artists

What is version control?

UNDO

Page 9: Introduction to Git for Artists

Versioned Files

Page 10: Introduction to Git for Artists

Local Version Control

Page 11: Introduction to Git for Artists

Centralized Version Control

Page 12: Introduction to Git for Artists

Distributed Version Control

Page 13: Introduction to Git for Artists

So, What is Git?

Page 14: Introduction to Git for Artists

Git is a way to

manageand

collaborateon large projects.

Page 15: Introduction to Git for Artists

What is Github?

Page 16: Introduction to Git for Artists

A place for code.

Page 17: Introduction to Git for Artists

A place for PUBLIC code.

Page 18: Introduction to Git for Artists

A PLACE FOR FORKS.

Page 19: Introduction to Git for Artists

Use someone else's

projectas astartingpointfor your own idea.

Page 20: Introduction to Git for Artists

Pull Requests

Page 21: Introduction to Git for Artists

Github flow:Fork it. Clone it. Branch it. Change it.Add it. Commit it. Push it. Pull Request it.

Page 22: Introduction to Git for Artists

Three Trees:

1.working directory

» This is the current directory.

2.staging/index

» this is everything added, but not committed

3.HEAD

» this is your last commit.

Page 23: Introduction to Git for Artists

Three repos:

1.local

» This is on your computer

2.origin

» this is yours on github

3.upstream

» this is the original, on github

Page 24: Introduction to Git for Artists

Get GitCommand Line:

http://git-scm.com/downloads

GUI:

https://windows.github.comorhttps://mac.github.com

Page 25: Introduction to Git for Artists

(make it so)

Page 26: Introduction to Git for Artists

Your First Defense git help <anything>

Page 27: Introduction to Git for Artists

Add your user infogit config --global user.name "John Doe"git config --global user.email [email protected]

# make it prettygit config --global color.ui true

Page 28: Introduction to Git for Artists

Add your editorgit config --global core.editor subl# orgit config --global core.editor mate# orgit config --global core.editor nano# if you're crazygit config --global core.editor vim# if you're craziergit config --global core.editor emacs

Page 29: Introduction to Git for Artists

Create ssh-keysFollow these instructions: https://help.github.com/articles/generating-ssh-keys/

TL;DR.

ssh-keygen -t rsa -C "[email protected]"pbcopy < ~/.ssh/id_rsa.pub# Upload to githubssh -T [email protected]

Page 30: Introduction to Git for Artists

Commands

Page 31: Introduction to Git for Artists

git init Create a new repository

git init pandatrackercd pandatracker

# or, if you already have a directory:git init .

Page 32: Introduction to Git for Artists

git status What's going on?

git status

Page 33: Introduction to Git for Artists

git status What's going on?

On branch masterChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)

modified: git.txt

no changes added to commit (use "git add" and/or "git commit -a")

Page 34: Introduction to Git for Artists

git clone Download a remote repository

git clone https://github.com/tadejm/sing-along.git

Page 35: Introduction to Git for Artists

git clone Download a remote repository

Cloning into 'sing-along'...remote: Counting objects: 89, done.remote: Total 89 (delta 0), reused 0 (delta 0)Unpacking objects: 100% (89/89), done.Checking connectivity... done.

Page 36: Introduction to Git for Artists

git add <filename> Add a file to staging

# add a single filegit add petunia.rb

# add the current directorygit add .

Page 37: Introduction to Git for Artists

git commit -m "message"Commit your changes to HEAD

git commit -m "Added the interface to the petunia neurons"

Page 38: Introduction to Git for Artists

git commit -m "message"Commit your changes to HEAD

[master 668ce5f] Added the interface to the petunia neurons 1 file changed, 1 insertion(+)

Page 39: Introduction to Git for Artists

git commitOpen your favorite text editor.

Page 40: Introduction to Git for Artists

MeaningfulCommitMessageswip

Page 41: Introduction to Git for Artists

MeaningfulCommitMessageswip

bugfixes

Page 42: Introduction to Git for Artists

MeaningfulCommitMessageswip

bugfixes

changed some stuff

Page 43: Introduction to Git for Artists

MeaningfulCommitMessageswip

bugfixes

changed some stuff

why on earth am I working at three am????

Page 44: Introduction to Git for Artists

MeaningfulCommitMessagesAdded the interface to the petunia neurons

We were having issues with interfacing telepathicallywith the flowers growing in the garden, so we'veadded a system that allows us to amplify their nuralmessages using a combination of jQuery and Miracle Grow.

Page 45: Introduction to Git for Artists

git push origin master Upload your code

git push origin master

Page 46: Introduction to Git for Artists

git push origin master Upload your code

fatal: 'origin' does not appear to be a git repositoryfatal: Could not read from remote repository.

Please make sure you have the correct access rightsand the repository exists.

Page 47: Introduction to Git for Artists

git push origin master Upload your code

# if you don't have a remotegit remote add origin <server>

# thengit push origin master

Page 48: Introduction to Git for Artists

git checkout -b <name> Create a branch

# create a branchgit checkout -b lasereyes

# go back to mastergit checkout master

# push to a remotegit push origin lasereyes

# Delete the branchgit branch -d lasereyes

Page 49: Introduction to Git for Artists

git pull get changes from a remote

git pull

Page 50: Introduction to Git for Artists

MERGE CONFLICTS

Page 51: Introduction to Git for Artists

Merge Conflicts# Find out what's upgit status

# If you want your version of a filegit checkout --ours petunia.rb

# If you want their version of a filegit checkout -theirs rose.rb

# If you fixed it manuallygit add daffoldil.rb

Page 52: Introduction to Git for Artists

Power Tools

Page 53: Introduction to Git for Artists

git log See the history of what you've done

git log

commit 668ce5fb3739e13beb61d01077421f32499e86f6Author: David Newbury <[email protected]>Date: Thu Jan 15 07:04:30 2015 -0500

Added the interface to the petunia neurons

commit 8397296d7867ffd05d836a8c11a203dd15cc4652Author: David Newbury <[email protected]>Date: Thu Jan 15 06:12:30 2015 -0500

I really really made a thing

Page 54: Introduction to Git for Artists

git stashPulling when you have uncommitted changes

git stashgit pull upstream developgit stash pop

Page 55: Introduction to Git for Artists

git commit --amendYou forgot something.

git commit -m "Fixed the wumpus"# (discover the wumpus is still broken)# ...# (actually fix the wumpus)git commit --amend

Page 56: Introduction to Git for Artists

git checkout -- <filename> Undo your current work

git checkout -- oops.rb# oops.rb is now reverted at the last commit

git reset --hard # All changes since your last commit are **GONE**.

git fetch origingit reset --hard origin/master# Everything is reverted to the master repo

Page 57: Introduction to Git for Artists

.gitignore Keep files out of the repo

_site*~*.pyc.DS_Store/tmp

Note: This is a file, not a command.

Page 58: Introduction to Git for Artists

git diff See the changes

diff --git a/petunia.rb b/petunia.rbindex 8895793..e6021aa 100644--- a/petunia.rb+++ b/petunia.rb@@ -1,4 +1,4 @@ # Do it. invigorate.the.petunias(100)

-run.from(petunias)+run.from(petunias).faster!

Page 59: Introduction to Git for Artists

Project Time

Page 60: Introduction to Git for Artists

https://github.com/workergnome/lies

1.Fork it.

2.Pull it locally

3.Create a branch.

4.Add a new file (yourlastname.txt)

5.Add and commit your changes

6.Push your branch to github

7.Submit a pull request.

Page 61: Introduction to Git for Artists

Helpful Linkshttp://rogerdudler.github.io/git-guide/http://rogerdudler.github.io/git-guide/files/git_cheat_sheet.pdf

...stack overflow.