git and github

18
git Thursday, May 23, 13

Upload: adam-bray

Post on 28-Oct-2014

473 views

Category:

Technology


3 download

DESCRIPTION

Introduction to git and github for YEI / STC Tech Bootcamp Summer 2013

TRANSCRIPT

Page 1: Git and Github

git

Thursday, May 23, 13

Page 2: Git and Github

and why learn it first?what is git?

Thursday, May 23, 13

Page 3: Git and Github

GIT HELPS US...

•track & undo changes (manage versions)

•collaborate on projects

•share code with others

Thursday, May 23, 13

Page 4: Git and Github

HOW DOES IT WORK?

•we create a git repository for a given project• this is a folder containing the project, and its entire history

• the history is stored as snapshots (called commits)

•the folder generally contains the latest version• this is called the working directory

•we interact with git using the git command

Thursday, May 23, 13

Page 5: Git and Github

HOW DOES IT WORK?•git only tracks the files we tell it to

• to track a file, we use git add filename

•each time we want to create a ‘savepoint’, we create a commit

•git only commits the changes we tell it to• to add a modified file to a commit, use git add filename

• this adds changes to the staging area

•to create a commit, use git commit -m “commit message”

Thursday, May 23, 13

Page 6: Git and Github

Thursday, May 23, 13

Page 7: Git and Github

GIT DEMO

git  config  -­‐-­‐global  user.name  "Adam  Bray”git  config  -­‐-­‐global  user.email  "[email protected]

Thursday, May 23, 13

Page 8: Git and Github

GIT DEMO

#  setup  vagrantcd  ~/path/to/your/codemkdir  assignment3vagrant  init  railsvagrant  upvagrant  ssh

Thursday, May 23, 13

Page 9: Git and Github

GIT DEMO

#  change  dir  to  shared  foldercd  /vagrant  

mkdir  git-­‐demogit  initgit  status

Thursday, May 23, 13

Page 10: Git and Github

GIT DEMO

touch  hello.rbsubl  .git  statusgit  add  hello.rbgit  commit  -­‐m  “created  hello  program”git  statusgit  log

Thursday, May 23, 13

Page 11: Git and Github

GIT DEMO

touch  bye.rbgit  statusgit  add  bye.rbgit  commit  -­‐m  “added  bye  program”git  statusgit  log

Thursday, May 23, 13

Page 12: Git and Github

github

Thursday, May 23, 13

Page 13: Git and Github

Thursday, May 23, 13

Page 14: Git and Github

CREATING A REPO ON GITHUB

•Login to github.com

•create a repository called git-demo

•follow instructions under “Push an existing repository from the command line”

Thursday, May 23, 13

Page 15: Git and Github

COMMON GITHUB WORKFLOW

#make  some  changes  to  filesgit  statusgit  add  .git  commit  -­‐m  “description  of  changes”#make  more  changes  and  repeat

git  pull  #check  for  conflictsgit  push  #send  changes  to  github

Thursday, May 23, 13

Page 16: Git and Github

CLONING A REPO

To  download  a  repo  for  the  first  time,  use:

git  clone  https://github.com/intro-­‐to-­‐rails-­‐course-­‐yale/git-­‐demo.git

Thursday, May 23, 13

Page 17: Git and Github

TIPS

•Commit often

•Commits should contain only related changes

•Don’t commit half-baked features

Thursday, May 23, 13

Page 18: Git and Github

SUMMARY

•git init #create a git repo

•git add filename #add file(s) to be committed

•git commit -m “message” #create a commit (savepoint)

•git pull / git push #get / send changes to github

•git status #check status of repo

•git log #look at commit history

Thursday, May 23, 13