21
Git

Learning Git

Embed Size (px)

Citation preview

Page 1: Learning Git

Git

Page 2: Learning Git

Overview• What is Git?

• Basic workflow

• Demo

• Tips

• Resources

Page 3: Learning Git

What is Git?

• Distributed revision control

• Stores snapshots of files

• Everything is local

Page 4: Learning Git

CVS, Subversion, Perforce

Deltas

Page 5: Learning Git

Git

Snapshots

Page 6: Learning Git

Key differences

• Everything is Local

• Fast

• Works offline

• Cheap branching

Page 7: Learning Git

Terms• commit - group of saved modifications

• remote - object which exists in a remote repository

• stash - unit of uncommitted changes

• tags - pointer to a specific commit in a specific branch

• can mark versions / milestones

Page 8: Learning Git

Terms

• push - upload changes made on the local repository to a remote repo / branch

• pull - download changes from a remote repo / branch to a local branch

Page 9: Learning Git

Common Actions• Check status

• Add changes to staging area

• Stash changes

• Commit staged changes

• Push commits

Page 10: Learning Git

Working with branches

• Create a branch

• Checkout another branch

• Merge branches

Page 11: Learning Git

Merging vs Rebase

• Merge - maintains commit history

• Rebase - squashes many commits into 1

Page 12: Learning Git

Basic Workflow

• Make some changes

• Stage changes

• Commit changes

• Push to remote (optional)

Page 13: Learning Git
Page 14: Learning Git

Well, actually…1. Create / Clone / Merge

2. Create new feature / issue branch

3. Make some changes

4. Stage & commit changes

5. Go back to 3

6. Submit for code review / Merge / Push

7. Go to 1

Page 15: Learning Git

Demo

Page 16: Learning Git

Why?• Collaboration

• Backup

• Experimentation (branches)

• Recover from mistakes

• Cross reference

Page 17: Learning Git

Do

• Use Git

• Branch often

• git checkout -b _issue##_

• Use .gitignore

Page 18: Learning Git

Don’t

• Commit binaries!

• Commit commented code

• use a branch or a stash

Page 19: Learning Git

Resources

• Github.gitignore files

• Git Cheat Sheet

• GUI

• SourceTree, GitHub, Tower, etc.

Page 20: Learning Git

Learn More

• Interactive tutorial

• Pro Git ebook

• Introduction to Git with Scott Chacon of GitHub

Page 21: Learning Git

Questions?

Thomas Bennett [email protected]