Slide 1

Slide 1 text

Version Control and How it Can Save Your Life @Rachell_Calhoun Git in Control DjangoCon US 2016

Slide 2

Slide 2 text

Git in Control 1. $whoami 2. Version control 3. Setting up Git 4. Basic Commands 5. Tricky Stuff 6. Gitiquette

Slide 3

Slide 3 text

$whoami git config -- global user.name "Rachell Calhoun" Git config $whoami

Slide 4

Slide 4 text

Rachell ( yes, with 2 Ls)

Slide 5

Slide 5 text

Git in Control 1. $whoami 2. Version control 3. Setting up Git 4. Basic Commands 5. Tricky Stuff 6. Gitiquette

Slide 6

Slide 6 text

Version control?

Slide 7

Slide 7 text

Solo Projects

Slide 8

Slide 8 text

Collaborating

Slide 9

Slide 9 text

Git in Control 1. $whoami 2. Version control 3. Setting up Git 4. Basic Commands 5. Tricky Stuff 6. Gitiquette

Slide 10

Slide 10 text

git config --global user.name "Jane Doe" git config --global user.email [email protected]

Slide 11

Slide 11 text

$ git init $ git remote add origin path/to/origin

Slide 12

Slide 12 text

$git clone path/to/remote/repo

Slide 13

Slide 13 text

Workflow Init/Clone

Slide 14

Slide 14 text

Git in Control 1. $whoami 2. Version control 3. Setting up Git 4. Basic Commands 5. Tricky Stuff 6. Gitiquette

Slide 15

Slide 15 text

$ git status

Slide 16

Slide 16 text

$ git status On branch branchname Untracked files: (use "git add ..." to include in what will be committed) list_of_passwords passwords2 nothing added to commit but untracked files present (use "git add" to track)

Slide 17

Slide 17 text

$ git add path/to/filename

Slide 18

Slide 18 text

$ git add filename

Slide 19

Slide 19 text

$ git add --all

Slide 20

Slide 20 text

Workflow Init/Clone > Add

Slide 21

Slide 21 text

$ git commit

Slide 22

Slide 22 text

$ git commit -m “...” git commit -m ”I made some awesome changes”.

Slide 23

Slide 23 text

Workflow Init/Clone > Add > Commit C1

Slide 24

Slide 24 text

$ git push

Slide 25

Slide 25 text

$ git push $ git push origin master $ git push origin branchname

Slide 26

Slide 26 text

Sum it up Init/Clone > Add > Commit > Push C1 C1

Slide 27

Slide 27 text

Branches

Slide 28

Slide 28 text

Branches Master work-branch party-branch P1 P2 W1 W2

Slide 29

Slide 29 text

$ git checkout -b work-branch Master work-branch

Slide 30

Slide 30 text

$ git branch -d work-branch Master

Slide 31

Slide 31 text

$ git push origin work-branch Origin work-branch W1 W2 Push Master work-branch

Slide 32

Slide 32 text

$ git branch master work-branch * party-branch

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

$ git fetch origin

Slide 35

Slide 35 text

$ git merge work-branch Master work-branch party-branch P1 P2 W1 W2 W1 W2 P1 P2

Slide 36

Slide 36 text

Conflicts

Slide 37

Slide 37 text

git pull = fetch + merge

Slide 38

Slide 38 text

Forking

Slide 39

Slide 39 text

Pull Request

Slide 40

Slide 40 text

Celebrate!

Slide 41

Slide 41 text

$ git remote add upstream path/to/original/repo

Slide 42

Slide 42 text

$ git pull upstream master

Slide 43

Slide 43 text

Git in Control 1. $whoami 2. Version control 3. Setting up Git 4. Basic Commands 5. Tricky Stuff 6. Gitiquette

Slide 44

Slide 44 text

Tricky stuff

Slide 45

Slide 45 text

$ git stash

Slide 46

Slide 46 text

$ git stash -u

Slide 47

Slide 47 text

Stash $ git stash apply $ git stash drop $ git stash pop

Slide 48

Slide 48 text

$ git stash branch party-branch

Slide 49

Slide 49 text

Undo Local Commits

Slide 50

Slide 50 text

Undo local commits $ git reset HEAD~2 $ git reset --hard HEAD~2 $ git reset --hard 234jk3

Slide 51

Slide 51 text

$ git rm list_of_passwords Removing files

Slide 52

Slide 52 text

Removing (added) files $ git reset list_of_passwords $ echo list_of_passwords >> .gitignore

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Edit a Commit Message $ git commit --amend $ git commit --amend -m "New message that sounds like I know what I’m doing!"

Slide 56

Slide 56 text

Add a Forgotten File $ git add forgotten_file $ git commit --amend $ git diff --stat --cached origin/master

Slide 57

Slide 57 text

Git in Control 1. $whoami 2. Version control 3. Setting up Git 4. Basic Commands 5. Tricky Stuff 6. Gitiquette

Slide 58

Slide 58 text

Gidiquette - Check issues - Branch naming - Keep changes small - Respect the coding style - Play nice with others

Slide 59

Slide 59 text

To Summarize: git config --global user.name git config --global user.email git init git remote add origin git clone git status git add git commit -m “...” git push git checkout -b branchname git branch -d branchname git push origin branchname git branch git fetch origin git merge branchname git pull Forking Compare and Pull Request git remote add upstream path/to/rep Git pull upstream master git stash git stash -u git stash apply git stash drop git stash pop git stash branch branchname git reset HEAD~2 git reset --hard HEAD~2 git reset --hard 234jk3 git rm list_of_passwords git reset list_of_passwords git commit --amend -m “...” git add forgotten_file git diff --stat --cached origin/master

Slide 60

Slide 60 text

Thank You! @Rachell_Calhoun