git and github
DESCRIPTION
Introduction to git and github for YEI / STC Tech Bootcamp Summer 2013TRANSCRIPT
git
Thursday, May 23, 13
and why learn it first?what is git?
Thursday, May 23, 13
GIT HELPS US...
•track & undo changes (manage versions)
•collaborate on projects
•share code with others
Thursday, May 23, 13
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
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
Thursday, May 23, 13
GIT DEMO
git config -‐-‐global user.name "Adam Bray”git config -‐-‐global user.email "[email protected]”
Thursday, May 23, 13
GIT DEMO
# setup vagrantcd ~/path/to/your/codemkdir assignment3vagrant init railsvagrant upvagrant ssh
Thursday, May 23, 13
GIT DEMO
# change dir to shared foldercd /vagrant
mkdir git-‐demogit initgit status
Thursday, May 23, 13
GIT DEMO
touch hello.rbsubl .git statusgit add hello.rbgit commit -‐m “created hello program”git statusgit log
Thursday, May 23, 13
GIT DEMO
touch bye.rbgit statusgit add bye.rbgit commit -‐m “added bye program”git statusgit log
Thursday, May 23, 13
github
Thursday, May 23, 13
Thursday, May 23, 13
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
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
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
TIPS
•Commit often
•Commits should contain only related changes
•Don’t commit half-baked features
Thursday, May 23, 13
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