75

Version control

  • Upload
    gaplabs

  • View
    190

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Version control
Page 2: Version control

Feb. 23, 2013

Version ControlBasics of Git

References:http://gitref.org

http://git-scm.com

Page 3: Version control

Feb. 23, 2013

Outline• What is Version Control• Why Version Control• Git as Version Control Tool

Page 4: Version control

Feb. 23, 2013

What

Page 5: Version control

Feb. 23, 2013

What Version Control

Page 6: Version control

Feb. 23, 2013

What Version Control

lets you track your files

Page 7: Version control

Feb. 23, 2013

What Version Control

lets you track your files

so when you mess up you can easily get back to a previous working version

Page 8: Version control

Feb. 23, 2013

Why

Page 9: Version control

Feb. 23, 2013

Why• Backup and Restore

Page 10: Version control

Feb. 23, 2013

Why• Backup and Restore• Synchronization

Page 11: Version control

Feb. 23, 2013

Why• Backup and Restore• Synchronization• Track Changes

Page 12: Version control

Feb. 23, 2013

Why• Backup and Restore• Synchronization• Track Changes• Track Ownership

Page 13: Version control

Feb. 23, 2013

How• Repository

where files are being stored

• Local Repositoryrepository in the local machine

• Remote Repositoryare versions of your project that are hosted over the Internet or network somewhere

Page 14: Version control

Feb. 23, 2013

Git: Basics

Page 15: Version control

Feb. 23, 2013

Git: Basics• Get / Create Repository

Page 16: Version control

Feb. 23, 2013

Git: Basics• Get / Create Repository

• Record Changes

Page 17: Version control

Feb. 23, 2013

Git: Basics• Get / Create Repository

• Record Changes

• Track History

Page 18: Version control

Feb. 23, 2013

Git: Basics• Get / Create Repository

• Record Changes

• Track History

• Undo Things

Page 19: Version control

Feb. 23, 2013

Git: Basics• Get / Create Repository

• Record Changes

• Track History

• Undo Things

• Sharing / Updating Files

Page 20: Version control

Feb. 23, 2013

working directory

remote repolocal repo

staging area

git-add git-commit git-push

git-fetch

git-checkout

git-reset

git-pull

git-diff

git-diff --staged

git-clone

Feb. 23, 2013

Page 21: Version control

Feb. 23, 2013

Create / Get

Page 22: Version control

Feb. 23, 2013

Create / Get

• get remote repository

Page 23: Version control

Feb. 23, 2013

Create / Get

• get remote repository git clone [repository url] [destination]

Page 24: Version control

Feb. 23, 2013

Create / Get

• get remote repository git clone [repository url] [destination]

• existing directory

Page 25: Version control

Feb. 23, 2013

Create / Get

• get remote repository git clone [repository url] [destination]

• existing directory git init [path/to/directory|file]

Page 26: Version control

Feb. 23, 2013

Record Changes

Page 27: Version control

Feb. 23, 2013

Record Changes

• Tracked Files

Page 28: Version control

Feb. 23, 2013

Record Changes

• Tracked FilesFi les that are currently in the repository

Page 29: Version control

Feb. 23, 2013

Record Changes

• Tracked FilesFi les that are currently in the repository

- unmodified, modified, staged

Page 30: Version control

Feb. 23, 2013

Record Changes

• Tracked FilesFi les that are currently in the repository

- unmodified, modified, staged

• Untracked Files

Page 31: Version control

Feb. 23, 2013

Record Changes

• Tracked FilesFi les that are currently in the repository

- unmodified, modified, staged

• Untracked Files Everything else

Page 32: Version control

Feb. 23, 2013

Tracking New Files

Page 33: Version control

Feb. 23, 2013

Tracking New Filesgit add [path/to/file|directory]

Page 34: Version control

Feb. 23, 2013

Tracking New Filesgit add [path/to/file|directory]

git-add command adds files to the staging area

Page 35: Version control

Feb. 23, 2013

Committing Staged Files

Page 36: Version control

Feb. 23, 2013

Committing Staged Files

git commit -m "message"

Page 37: Version control

Feb. 23, 2013

Committing Staged Files

git commit -m "message"

git-commit command commits all staged files

Page 38: Version control

Feb. 23, 2013

Ignoring Files

Page 39: Version control

Feb. 23, 2013

Ignoring Files• Blank lines or lines starting with # are ignored.

Page 40: Version control

Feb. 23, 2013

Ignoring Files• Blank lines or lines starting with # are ignored.

• Standard glob patterns work.

Page 41: Version control

Feb. 23, 2013

Ignoring Files• Blank lines or lines starting with # are ignored.

• Standard glob patterns work.

• You can end patterns with a forward slash (/) to specify a directory.

Page 42: Version control

Feb. 23, 2013

Ignoring Files• Blank lines or lines starting with # are ignored.

• Standard glob patterns work.

• You can end patterns with a forward slash (/) to specify a directory.• You can negate a pattern by starting it with an exclamation point (!).

Page 43: Version control

Feb. 23, 2013

Staged and Unstaged Changes

Page 44: Version control

Feb. 23, 2013

Staged and Unstaged Changes

git diff

Page 45: Version control

Feb. 23, 2013

Staged and Unstaged Changes

git diff shows diff of what is modified but unstaged

Page 46: Version control

Feb. 23, 2013

Staged and Unstaged Changes

git diff shows diff of what is modified but unstaged

git diff --staged

Page 47: Version control

Feb. 23, 2013

Staged and Unstaged Changes

git diff shows diff of what is modified but unstaged

git diff --stagedshows the changes that will currently go into the next commit.

Page 48: Version control

Feb. 23, 2013

Removing Files

Renaming Files

Tracking History

Page 49: Version control

Feb. 23, 2013

Removing Filesgit rm [file/directory]

Renaming Files

Tracking History

Page 50: Version control

Feb. 23, 2013

Removing Filesgit rm [file/directory]

git mv current_file_name new_file_name

Renaming Files

Tracking History

Page 51: Version control

Feb. 23, 2013

Removing Filesgit rm [file/directory]

git mv current_file_name new_file_name

Renaming Files

Tracking Historygit log

Page 52: Version control

Feb. 23, 2013

Undoing Things

Page 53: Version control

Feb. 23, 2013

Undoing Things• Unstaging staged file

Page 54: Version control

Feb. 23, 2013

Undoing Things• Unstaging staged file

git reset HEAD <file>

Page 55: Version control

Feb. 23, 2013

Undoing Things• Unstaging staged file

git reset HEAD <file>

• Unmodifying modified file

Page 56: Version control

Feb. 23, 2013

Undoing Things• Unstaging staged file

git reset HEAD <file>

• Unmodifying modified file git checkout -- <file>

Page 57: Version control

Feb. 23, 2013

Undoing Things

These commands are actually suggested when running git-status command

• Unstaging staged filegit reset HEAD <file>

• Unmodifying modified file git checkout -- <file>

Page 58: Version control

Feb. 23, 2013

Sharing / Updating Files

Page 59: Version control

Feb. 23, 2013

Sharing / Updating FilesRemote Repositories

Page 60: Version control

Feb. 23, 2013

Sharing / Updating FilesRemote Repositories

are versions of your project that are hosted over the Internet or network somewhere.

Page 61: Version control

Feb. 23, 2013

Sharing / Updating FilesRemote Repositories

are versions of your project that are hosted over the Internet or network somewhere.

• Show remote repository

Page 62: Version control

Feb. 23, 2013

Sharing / Updating FilesRemote Repositories

are versions of your project that are hosted over the Internet or network somewhere.

• Show remote repository• Add remote repository

Page 63: Version control

Feb. 23, 2013

Sharing / Updating FilesRemote Repositories

are versions of your project that are hosted over the Internet or network somewhere.

• Show remote repository• Add remote repository• Update/Sync remote repository

Page 64: Version control

Feb. 23, 2013

Sharing / Updating FilesRemote Repositories

are versions of your project that are hosted over the Internet or network somewhere.

• Show remote repository• Add remote repository• Update/Sync remote repository• Inspect remote repository

Page 65: Version control

Feb. 23, 2013

Remote Repository

Page 66: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

Page 67: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v

Page 68: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

Page 69: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]

Page 70: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]• Update remote repository

Page 71: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]• Update remote repository

git push [alias] [branch]

Page 72: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]• Update remote repository

git push [alias] [branch]• Sync with remote

Page 73: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]• Update remote repository

git push [alias] [branch]• Sync with remote

git pull [alias] [branch]

Page 74: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]• Update remote repository

git push [alias] [branch]• Sync with remote

git pull [alias] [branch]• Inspect remote repository

Page 75: Version control

Feb. 23, 2013

Remote Repository• Show remote repository

git remote -v• Add remote repository

git remote add [alias] [repository url]• Update remote repository

git push [alias] [branch]• Sync with remote

git pull [alias] [branch]• Inspect remote repository

git remote show [alias]