atlanta pm git 101

23
Git and GitHub.com

Upload: jason-noble

Post on 11-May-2015

1.237 views

Category:

Technology


2 download

DESCRIPTION

Intro to Git for Atlanta Perl Mongers.

TRANSCRIPT

Page 1: Atlanta Pm Git 101

Git and GitHub.com

Page 2: Atlanta Pm Git 101

Git 101

• Git is a distributed revision control system

• Keeps track of changes made to one or more files over time

• Shows log messages of what changed and why

• Allows developers to share their changes easily

Page 3: Atlanta Pm Git 101

Git Project Sections

Source: http://progit.org/book/ch1-3.html

Page 4: Atlanta Pm Git 101

Git workflow

Modify Files

Stage FilesCommit Files

Page 5: Atlanta Pm Git 101

Installing Git

• Covered in detail at http://progit.org/book/ch1-4.html

Page 6: Atlanta Pm Git 101

Initial Setup

• git config --global user.name “John Doe”• git config --global user.email [email protected]

• git config --global core.editor emacs– By default, it uses GIT_EDITOR, VISUAL or EDITOR Environment

variables– Other editors are vi, mate -m, nano, etc

• git config --list– Shows your git settings

• See http://progit.org/book/ch1-5.html for more

Page 7: Atlanta Pm Git 101

Getting help

• Most Git commands have help available

• git help commit• git help branch• git help tag

Page 8: Atlanta Pm Git 101

Getting started with Git

• mkdir project_name• cd project_name• git init• echo “Hello” >> README

• git add README

• git commit -m ‘Initial commit’

Page 9: Atlanta Pm Git 101

Getting started Lab

• Create a new directory

• Initialize git

• Create/Edit a file

• Add/Stage that file

• Commit the stage to your local repo

• Repeat

Page 10: Atlanta Pm Git 101

Working with remote reposPublic RepoLocated on Server (Github)

Private RepoLocated on your local machine

git pull git push

Page 11: Atlanta Pm Git 101

Signup with Github• https://github.com/signup/free

– You can skip SSH Public Key, we’ll come back to it

Page 12: Atlanta Pm Git 101

Setup SSH Keys

• ssh-keygen -d

Page 13: Atlanta Pm Git 101

Setup local SSH config

• If you don’t use your “default” ssh key for GitHub, you need to tell SSH to use your Github key

Page 14: Atlanta Pm Git 101

Add SSH Key to GitHub

• https://github.com/account

Page 15: Atlanta Pm Git 101

Create my_project repo(on Github.com)

• https://github.com/

Page 16: Atlanta Pm Git 101

Add remote repo to your local repo

• cd my_project• git remote add origin [email protected]:your-user-name/my_project.git

• git push origin master– “origin” is configurable name

– “origin” is convention for GitHub

• View changes at http://github.com/your-user-name/my_project

Page 17: Atlanta Pm Git 101

Remote repos processPublic RepoLocated on Server (Github)

Private RepoLocated on your local machine

git push

Make file changesStage ChangesCommit Changes

git add filenamegit commit -m ‘…’ vi filename

Page 18: Atlanta Pm Git 101

Commit changes and push to remote repo

• cd my_project• echo “bye” >> README• git add README• git commit -m ‘Added bye to README’

• git push origin masterOR

• git push

• View changes at http://github.com/your-user-name/my_project

Page 19: Atlanta Pm Git 101

Lab with remote repos(on Github.com)

• Modify file locally

• Add/Stage that file to the commit

• Commit your changes

• Push those changes to GitHub

Page 20: Atlanta Pm Git 101

Remote repos process(multiple committers)

Public RepoLocated on Server (Github)

Private RepoLocated on your local machine

1) git push

Make file changesStage ChangesCommit Changes

git add filenamegit commit -m ‘…’ vi filename

Bob’s Private RepoLocated on Bob’s local machine

2) git pull

Page 21: Atlanta Pm Git 101

Remote repos process(multiple committers)

Public RepoLocated on Server (Github)

Private RepoLocated on your local machine

2) git pull

Bob’s Private RepoLocated on Bob’s local machine

Make file changesStage ChangesCommit Changes

git add filenamegit commit -m ‘…’ vi filename

1) git push

Page 22: Atlanta Pm Git 101

Pull commits from remote repo

• cd my_project

• git pull origin masterOR

• git pull

Page 23: Atlanta Pm Git 101

Lab with remote repos(on Github.com)

User A

• Modify file locally

• Add/Stage that file to the commit

• Commit your changes

• Push those changes to GitHub

User B

• Pull those changes from GitHub