Slide 1

Slide 1 text

Git shared insights

Slide 2

Slide 2 text

Agenda ● Git tools ● Git config, Git config files ● Gitignore files ● Branching, merging, rebasing ● Pulling ● Squashing, amend commit ● Git Workflow, Feature Branch Workflow ● Workflow of my team ● Demo ● Hints

Slide 3

Slide 3 text

Git tools (Bitbucket)

Slide 4

Slide 4 text

Git tools (Sourcetree)

Slide 5

Slide 5 text

Git tools (IntelliJ)

Slide 6

Slide 6 text

Git tools (Visual Studio Code)

Slide 7

Slide 7 text

Git tools (Terminal)

Slide 8

Slide 8 text

# Lists the git config git config -l git config --global -l # Sets colored output git config --global color.ui auto # Sets converting of LF endings into CRLF git config --global core.autocrlf input # for mac and linux git config --global core.autocrlf auto # for windows # Sets user details git config --global user.name "Markus Hanses" git config --global user.email "[email protected]" Git config

Slide 9

Slide 9 text

Git config files cat ~/.gitconfig cat repo/.git/config [user] name = Markus Hanses email = [email protected] [core] excludesfile = .gitignore_global autocrlf = input [color] ui = auto ... [core] ... [remote "origin"] url = ... fetch = ... [branch "master"] remote = origin merge = refs/heads/master ...

Slide 10

Slide 10 text

Gitignore files cat ~/.gitignore_global cat repo/.gitignore *~ .DS_Store ... /.idea *.iml /build /**/*log ...

Slide 11

Slide 11 text

branching 1/2 (create) git checkout -b feature_one git add . git commit -m “Your message” git push --set-upstream origin feature_one

Slide 12

Slide 12 text

branching 2/2 (delete) git branch -d feature_four git push origin --delete feature_four

Slide 13

Slide 13 text

Merging (fast forward) git checkout master git merge -ff feature_one git push

Slide 14

Slide 14 text

Merging (No fast forward) git checkout master git merge --no-ff feature_four -m 'add new feature' git push

Slide 15

Slide 15 text

Rebasing git checkout feature_eight git rebase master git push -f #! rebase onto master

Slide 16

Slide 16 text

Pulling (merge) git pull # git fetch & git merge Quelle: https://de.atlassian.com/git/tutorials/syncing/git-pull

Slide 17

Slide 17 text

Pulling (Rebase) git pull --rebase # git fetch & git rebase

Slide 18

Slide 18 text

Squashing 1/2 time

Slide 19

Slide 19 text

Squashing 2/2 git rebase -i 18c1a589b65 git push -f

Slide 20

Slide 20 text

Mini Squashing (amend commit) git add . git commit --amend -m “Typo corrected”

Slide 21

Slide 21 text

Git Workflow Quelle: https://de.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Slide 22

Slide 22 text

Feature Branch Workflow Quelle: https://github.com/IntegratedBreedingPlatform/Documentation/wiki/Git-Workflow

Slide 23

Slide 23 text

Workflow of my team 1/2

Slide 24

Slide 24 text

Workflow of my team 2/2

Slide 25

Slide 25 text

Demo Time

Slide 26

Slide 26 text

Hints 1/2 (Save time) # Sets the push strategy to 'use the same name on remote' git config --global push.default simple # Deletes local references for deleted remote branches git config --global fetch.prune 1 # Store passwords in MAC OS password manager git config --global credential.helper osxkeychain # Create an alias for an compressed log output git config --global alias.ultimate-log "log --graph --oneline --decorate"

Slide 27

Slide 27 text

Hints 1/2 (Clean repository) # Removes all merged local branches, but 'master' branch git branch | grep -v "master" | xargs git branch -d # Removes all remote branches, merged into master git branch -r --merged master | \ ack -v master | \ sed -e 's/\// :/' | \ xargs -n2 git push

Slide 28

Slide 28 text

Recommended sources ● GIT Website, https://git-scm.com/docs ● Bitbucket Website, https://de.atlassian.com/git/tutorials ● Git in Practice, Mike McQuaid, Manning ● Pro Git 2nd Edition, Scott Chacon and Ben Straub, apress

Slide 29

Slide 29 text

git reset -hard

Slide 30

Slide 30 text

end of presentation Author: Markus Hanses Date: 2018-12-20