getting git

Basics
• Fast
• Flexible
Local VCS

Centralized VCS

Yay
• Access control• Central Backup
Nay
• Single point of failure• Painful merges
Decentralized VCS

Yay
• Every clone is a forkNay
• Not good for large binary filesGit design goals
Tracking Changes

Tracking Snapshots

Git is a file system
Git thinks of its data more like a set of snapshots of a mini filesystem.
Git has integrity
24b9da6552252987aa493b52f8696cd6d3b00373
Git doesn't delete
The three states
- Modified
- Staged
- Committed
Workflow

The git directory
The working directory
The Staging Area
File Status Lifecycle

Installing Git

Installing Git
Windows
Linux
OS X
Configuration
Identity
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
Editor
$ git config --global core.editor vim
Colors
$ git config --global color.ui true
Creating a Repository
$ git init
Cloning a Repository
Creating a Commit
Specific changes:
All changes:
Removing files
From staging area
$ git rm --cached file.py
From index and file system
Moving files
Git tracks content, not files. Although there is a move command...
$ git mv file1 file2
...this is the same as...
$ mv file1 file2
$ git rm file1
$ git add file2
Show Status
Show log
Entire (paged)
Date filtering
SHOW Diffs
Unstaged changes
Staged changes
Relative to specific revision
Show Commits
Last commit
Specific commit
Undoing Things
Change last commit
Unstage staged file
Unmodify modified file
Revert a commit
.gitignore
$ cat .gitignore
*.pyc
*.swp
/build/
/doc/[abc]*.txt
.pypirc
*.egg-info
• Blank lines or lines starting with # are ignored
• Standard glob patterns work
• End pattern with slash (/) to specify a directory
• Negate pattern with exclamation point (!)
Remotes
$ git remote -v
origin git://github.com/schacon/ticgit.git (fetch)
origin git://github.com/schacon/ticgit.git (push)
Push to remote
Without default
Setting A default
Then...
Pull from Remote
Fetch & Merge
$ git pull [<remote> <rbranch>]
Fetch & Rebase
$ git pull --rebase [<remote> <rbranch>]
-> Rebasing can be dangerous!
Create Tags
Lightweight tags
Annotated tags
GPG-Signed tags
Branches

Diverging Branches

Merging Branches

Merge conflicts
$ git merge iss53 Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.
• Then mark as resolved and trigger merge commit
$ git add index.html
$ git commit
Usually painless

Rebasing

Branch Management
Create new branch
$ git branch iss53
$ git checkout -b iss53 master
Switch Branch
$ git checkout iss53
Delete Branch
$ git branch -d iss53
Branch Management
Show All Branches
$ git branch
iss53
* master
testing
Show last Branch commits
$ git branch -v
iss53 93b412c fix javascript issue
* master 7a98805 Merge branch 'iss53'
testing 782fd34 add scott to the author list in the readmes
Branch Management
Merged branches
$ git branch --merged
iss53
* master
Unmerged branches
$ git branch --no-merged
testing
Stashing
Common Workflow

Workflow 1
Workflow 2
Topic Branches
Legit

Advanced Git
Autocompletion
Aliases
Advanced Git
Partial add
Bisecting
Advanced Git
Rewrite commits
Resources
Now Git to work!
.png)
Legal
License



CC BY-SA 3.0
Attribution
deck
By mamamiya92
deck
- 977