doghouse university - git basics

13
DOGHOUSE UNIVERSITY Git Basics

Upload: doghouse-university

Post on 03-Aug-2015

49 views

Category:

Software


1 download

TRANSCRIPT

DOGHOUSE UNIVERSITY!Git Basics

What is git?

1. Source Control Management System (SCM)!

2. Distributed!

3. Speed!

4. Data integrityhttp://www-cs-students.stanford.edu/~blynn/gitmagic/ch08.html

Commands

1. git init!

2. git add <path>!

3. git commit!

4. git checkout <ref>

Branching

1. git branch <branch>!

2. git branch -a!

3. git branch -d!

4. git branch -D

Remotes

1. git clone <url>!

2. git remote add <remote> <url>!

3. git remote set-url <remote> <url>!

4. git push <remote> <branch>!

5. git pull <remote> <branch>

Remote tracking

1. git branch -t <branch>!

2. git checkout -t -b <branch>!

3. git fetch --all -ap

Merge vs Rebase

1. git merge <branch>!

2. git rebase <branch>

Squash

git merge —squash <branch>

# Reset the current branch to the commit just before the last 12: git reset --hard <commit> !# HEAD@{1} is where the branch was just before the previous command. # This command sets the state of the index to be as it would just # after a merge from that commit: git merge --squash HEAD@{1} !# Commit those squashed changes. The commit message will be helpfully # prepopulated with the commit messages of all the squashed commits: git commit

Option 2

Option 1

Don’t be evil!

1. Commit often!

2. Check your diffs BEFORE pushing git diff, Gitk, SourceTree App!

3. Do not add/commit blindlygit add -A .git commit -m “More styling”!

4. Create Pull Requests often!

5. Branch for everything!

6. Think of what the history will look like!

Other Stuff

1. git cherry-pick!

2. git reset!

3. git revert

Let’s Play!

1. http://pcottle.github.io/learnGitBranching/!

2. https://github.com/Gazler/githug