Top Banner
Git Obstacle Course Stop BASHing your head and break down the basics
82

Git Obstacle Course: Stop BASHing your head and break down the basics

Jan 08, 2017

Download

Technology

Chris Bohatka
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Git Obstacle Course: Stop BASHing your head and break down the basics

Git Obstacle Course Stop BASHing your head and break down the

basics

Page 2: Git Obstacle Course: Stop BASHing your head and break down the basics

about me• Cleveland, OH

• .NET Web Developer

• CardinalCommerce

• @cjb5790

• http://chris.bohatka.com

Page 3: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 4: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 5: Git Obstacle Course: Stop BASHing your head and break down the basics

why should I get git?• decentralized

• works offline (default)

• flexible

• lightweight

• widely supported

• better control

Page 6: Git Obstacle Course: Stop BASHing your head and break down the basics

install git (windows)

Page 7: Git Obstacle Course: Stop BASHing your head and break down the basics

install git (windows)

Page 8: Git Obstacle Course: Stop BASHing your head and break down the basics

install git (mac)

Page 9: Git Obstacle Course: Stop BASHing your head and break down the basics

now what?

Page 10: Git Obstacle Course: Stop BASHing your head and break down the basics

lets create our first repo

but how?

Page 11: Git Obstacle Course: Stop BASHing your head and break down the basics

tools

Page 12: Git Obstacle Course: Stop BASHing your head and break down the basics

github for windows

Page 13: Git Obstacle Course: Stop BASHing your head and break down the basics

atlassian sourcetree

Page 14: Git Obstacle Course: Stop BASHing your head and break down the basics

axosoft gitkraken

Page 15: Git Obstacle Course: Stop BASHing your head and break down the basics

git bash• shell running in cygwin

• cygwin = terminal

• terminal = program that runs a shell

• shell = program that runs commands

• console = type of terminal

Page 16: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 17: Git Obstacle Course: Stop BASHing your head and break down the basics

command line (CLI)

Page 18: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 19: Git Obstacle Course: Stop BASHing your head and break down the basics

Terminal

=

Bash

Page 20: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 21: Git Obstacle Course: Stop BASHing your head and break down the basics

basic bash commands

ls list files in current directory

cd change current directory

touch create a new blank file

rm remove a file

mv “move” - rename file

mkdir create a new directory

rmdir remove a directory

rm -rf remove directory and contents

more show the contents of a file

Page 22: Git Obstacle Course: Stop BASHing your head and break down the basics

creating a repo

git init

Page 23: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 24: Git Obstacle Course: Stop BASHing your head and break down the basics

add files

git add <filename>

Page 25: Git Obstacle Course: Stop BASHing your head and break down the basics

stage• all files that will be committed, but have not been committed yet

Page 26: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 27: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 28: Git Obstacle Course: Stop BASHing your head and break down the basics

git ignore

Page 29: Git Obstacle Course: Stop BASHing your head and break down the basics

let’s commit

Page 30: Git Obstacle Course: Stop BASHing your head and break down the basics

how to commit

git commit

Page 31: Git Obstacle Course: Stop BASHing your head and break down the basics

but before we commit...

Page 32: Git Obstacle Course: Stop BASHing your head and break down the basics

...ALWAYS diff!

Page 33: Git Obstacle Course: Stop BASHing your head and break down the basics

ALWAYS diff

git diff

Page 34: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 35: Git Obstacle Course: Stop BASHing your head and break down the basics

git difftool

git difftool -t <tool name>

git difftool

Page 36: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 37: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 38: Git Obstacle Course: Stop BASHing your head and break down the basics

git difftool

git config --global diff.tool kdiff3

Page 39: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 40: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 41: Git Obstacle Course: Stop BASHing your head and break down the basics

git != svn | tfs | vss

Page 42: Git Obstacle Course: Stop BASHing your head and break down the basics

git commit

git commit -a

git commit -a -m

git commit -a -m “[commit message]”

Page 43: Git Obstacle Course: Stop BASHing your head and break down the basics

commit early, commit often

Page 44: Git Obstacle Course: Stop BASHing your head and break down the basics

branches

Page 45: Git Obstacle Course: Stop BASHing your head and break down the basics

branches• branching is EXTREMELY cheap in git

• performant

• easy (straight-forward)

• you will branch A LOT

• most branches will be local only

• branch life expectancy is very short

Page 46: Git Obstacle Course: Stop BASHing your head and break down the basics

branches

git branch shiny-new-feature

git checkout shiny-new-feature

Page 47: Git Obstacle Course: Stop BASHing your head and break down the basics

git checkout• switches active branch

• doesn’t actually ‘pull’ any files

• unless you “git fetch”

Page 48: Git Obstacle Course: Stop BASHing your head and break down the basics

creating a branch

Page 49: Git Obstacle Course: Stop BASHing your head and break down the basics

removing a branch

Page 50: Git Obstacle Course: Stop BASHing your head and break down the basics

git merge

git merge <name-of-branch>

Page 51: Git Obstacle Course: Stop BASHing your head and break down the basics

git mergetool• resolve merge conflicts using GUI of your choice

• KDiff3 - http://kdiff3.sourceforge.net

• AraxisMerge - http://www.araxis.com/merge/index.en

git mergetool -t <tool name>

Page 52: Git Obstacle Course: Stop BASHing your head and break down the basics

git mergetool

git config --global mergetool.kdiff3.path /Applications/kdiff3.app/Contents/MacOS/kdiff3

Page 53: Git Obstacle Course: Stop BASHing your head and break down the basics

git mergetool

git mergetool -t kdiff3

Page 54: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 55: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 56: Git Obstacle Course: Stop BASHing your head and break down the basics

git mergetool

git config --global merge.tool kdiff3

Page 57: Git Obstacle Course: Stop BASHing your head and break down the basics

git mergetool

git mergetool

Page 58: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 59: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 60: Git Obstacle Course: Stop BASHing your head and break down the basics

remotes

Remote(GitHub, Bitbucket,

etc)

Clone #1(My PC)

Clone #2(Co-Worker’s

PC)

Page 61: Git Obstacle Course: Stop BASHing your head and break down the basics

repository hosts

https://github.com https://bitbucket.org

Page 62: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 63: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 64: Git Obstacle Course: Stop BASHing your head and break down the basics

how to pull/push

git pull

git push

Page 65: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 66: Git Obstacle Course: Stop BASHing your head and break down the basics

git revert & reset• revert

• single commit

• reset

• all changes since last commit

git revert <commit> git reset

Page 67: Git Obstacle Course: Stop BASHing your head and break down the basics

git cherry-pick

git cherry-pick <revision>

Page 68: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 69: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 70: Git Obstacle Course: Stop BASHing your head and break down the basics

gitflow• promotes positive development workflow

• easily differentiates new features and bugs

• streamlines release management

• allows easy “logging” of changes

* http://nvie.com/posts/a-successful-git-branching-model/

Page 71: Git Obstacle Course: Stop BASHing your head and break down the basics

tags

git tag -a <version> -m <commit message>

git tag -a v1.0 -m ‘MVP launch’

Page 72: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 73: Git Obstacle Course: Stop BASHing your head and break down the basics

git aliases• git command

• stores in git config file

• user specific

git config --global alias.nameOfAlias “command to alias”

Page 74: Git Obstacle Course: Stop BASHing your head and break down the basics

git aliases

git config --global alias.hadouken ‘push’

git config --global alias.cm ‘commit -a -m’

git config --global alias.glog ‘log --graph’

Page 75: Git Obstacle Course: Stop BASHing your head and break down the basics

commit with alias

Page 76: Git Obstacle Course: Stop BASHing your head and break down the basics

bash aliases• shell level shortcut

alias nameOfAlias=“command to alias”

Page 77: Git Obstacle Course: Stop BASHing your head and break down the basics

bash aliases

alias gcm=‘git commit -a -m’

alias gpull=‘git pull’

alias gpush=‘git push’

alias newrepo=‘git init’

Page 78: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 79: Git Obstacle Course: Stop BASHing your head and break down the basics

git autocorrect

git config --global help.autocorrect 10

Page 80: Git Obstacle Course: Stop BASHing your head and break down the basics
Page 81: Git Obstacle Course: Stop BASHing your head and break down the basics

resources• https://git-scm.com/doc

• https://try.github.io

• https://www.atlassian.com/git/

• https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf

Page 82: Git Obstacle Course: Stop BASHing your head and break down the basics

thank you

@cjb5790