Top Banner
/tutorial/git Thomas Rausch [email protected] Institute for Information Systems Distributed Systems Group TU Wien
148

Git Introduction Tutorial

Feb 17, 2017

Download

Software

Thomas Rausch
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 Introduction Tutorial

/tutorial/git

Thomas [email protected]

Institute for Information SystemsDistributed Systems Group

TU Wien

Page 2: Git Introduction Tutorial

http://git-scm.com

Page 3: Git Introduction Tutorial

Of Linus and learning curves

“Linus is a guy who delights in being cruel to people …”

Page 4: Git Introduction Tutorial

Of Linus and learning curves

“Linus is a guy who delights in being cruel to people …”

“His latest cruel act is to create a revision control system which is expressly designed to make you feel less intelligent than you thought you were” [1]

[1]: Tech Talk: Linus Torvalds on git - http://youtu.be/4XpnKHJAok8

Page 5: Git Introduction Tutorial

Of Linus and learning curves

Page 6: Git Introduction Tutorial

What you should take from today

Page 7: Git Introduction Tutorial

What you should take from today

git =

Page 8: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 9: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 10: Git Introduction Tutorial

basics stages branch merge remotes advanced

$ git config --global user.name "Thomas Rausch"$ git config --global user.email [email protected]

Configure your user

Page 11: Git Introduction Tutorial

basics stages branch merge remotes advanced

$ git initInitialized empty Git repository in /home/thomas/git-tutorial/.git/

Initialize an empty repository

$ git clone <repo> [<directory>]

Clone a remote repository

Page 12: Git Introduction Tutorial

basics stages branch merge remotes advanced

Check the status of your repository

$ git status# On branch master## Initial commit## Untracked files:# (use "git add <file>..." to include in what will be committed)## README.md# src/nothing added to commit but untracked files present (use "git add" to track)

$ git status -sb# Initial commit on master?? README.md?? src

Page 13: Git Introduction Tutorial

basics stages branch merge remotes advanced

$ git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." to unstage)## new file: README.md#

$ git add README.md

Start tracking files

Page 14: Git Introduction Tutorial

basics stages branch merge remotes advanced

Commit changes

$ git status# On branch masternothing to commit (working directory clean)

$ git commit -m "add readme file"[master (root-commit) d4c59ff] add readme file 1 file changed, 3 insertions(+) create mode 100644 README.md

Page 15: Git Introduction Tutorial

basics stages branch merge remotes advanced

View differences of current unstaged modifications

$ git diff --colordiff --git a/src/Main.java b/src/Main.javaindex 66c8e93..dcdf6cb 100644--- a/src/Main.java+++ b/src/Main.java@@ -1,5 +1,7 @@ class Main {+ static int status = 0;+ public static void main(String[] args) {- System.exit(0);+ System.exit(status); } }

Page 16: Git Introduction Tutorial

basics stages branch merge remotes advanced

Unstaging files

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## new file: src/HelloWien.java# new file: src/HelloWorld.java

$ git reset HEAD src/HelloWien.java

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## new file: src/HelloWorld.java## Untracked files:# (use "git add <file>..." to include in what will be committed)## src/HelloWien.java#

Page 17: Git Introduction Tutorial

basics stages branch merge remotes advanced

Undoing local unstaged changes

$ git status# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: README.md

$ git checkout -- README.md

$ git status# On branch masternothing to commit (working directory clean)

Page 18: Git Introduction Tutorial

basics stages branch merge remotes advanced

Viewing the history

$ git logcommit 9c3cb834c43d67cc37b15e74b64dc830c1e78199Author: Thomas Rausch <[email protected]>Date: Mon Oct 14 00:04:53 2013 +0100

modified readme file

commit d4c59ffd7e676dad6aef2cc244b87e3c579aa904Author: Thomas Rausch <[email protected]>Date: Sun Oct 13 23:45:39 2013 +0100

add readme file

$ git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit -date=relative* 9c3cb83 Thomas Rausch: modified readme file - (HEAD, master) (4 minutes ago)* d4c59ff Thomas Rausch: add readme file - (24 minutes ago)

$ git log --oneline9c3cb83 modified readme filed4c59ff add readme file

Page 19: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 20: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 21: Git Introduction Tutorial

working directory

basics stages branch merge remotes advanced

Page 22: Git Introduction Tutorial

working directory

staging area

basics stages branch merge remotes advanced

Page 23: Git Introduction Tutorial

working directory

staging area

repository

basics stages branch merge remotes advanced

Page 24: Git Introduction Tutorial

working directory

staging area

repository

git add

basics stages branch merge remotes advanced

Page 25: Git Introduction Tutorial

working directory

staging area

repository

git add

git commit

basics stages branch merge remotes advanced

Page 26: Git Introduction Tutorial

working directory

staging area

repository

git commit -a

basics stages branch merge remotes advanced

Page 27: Git Introduction Tutorial

working directory

staging area

repository

basics stages branch merge remotes advanced

git reset HEAD <file>

Page 28: Git Introduction Tutorial

working directory

staging area

repository

git reset HEAD <file> git checkout

basics stages branch merge remotes advanced

Page 29: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 30: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 31: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 32: Git Introduction Tutorial

basics stages branch merge remotes advanced

$ git branch develop* master new-feature

List branches

Page 33: Git Introduction Tutorial

basics stages branch merge remotes advanced

$ git branch develop* master new-feature

List branches

Branch you havecurrently

checked out

Page 34: Git Introduction Tutorial

basics stages branch merge remotes advanced

$ git checkout developSwitched to branch 'develop'

Change into a branch

Page 35: Git Introduction Tutorial

basics stages branch merge remotes advanced

Manage branches

$ git branch <branch>

Create a new branch from the one you have currently checked out

$ git branch -m <oldbranch> <newbranch>

Rename a branch

$ git branch -D <branch>

Delete a branch

Page 36: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 37: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 38: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 39: Git Introduction Tutorial

basics stages branch merge remotes advanced

Merge branches

$ git checkout master$ git merge topic

Merge the specified branch into the current branch (the one you have checked out)

Merges topicinto master

Page 40: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

topic

master

topic

Page 41: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

topic

master

topic

Fast-forward

Page 42: Git Introduction Tutorial

topic

basics stages branch merge remotes advanced

master

master, topic

Fast-forward

Page 43: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

topic

master

topic

Page 44: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

topic

master

topic

Recursive three-way

Page 45: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

topic

A merge commitwith 2 parents

Recursive three-way

Page 46: Git Introduction Tutorial

basics stages branch merge remotes advanced

Conflicts

Page 47: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

Page 48: Git Introduction Tutorial

basics stages branch merge remotes advanced

class Main { public static void main(String... args) { }}

master

Page 49: Git Introduction Tutorial

basics stages branch merge remotes advanced

class Main { public static void main(String... args) { }}

master topic

Page 50: Git Introduction Tutorial

basics stages branch merge remotes advanced

class Main { public static void main(String... args) { }}

class Main { static int status = 0;

public static void main(String... args) { System.exit(status); }}

master topic

Page 51: Git Introduction Tutorial

basics stages branch merge remotes advanced

class Main { public static void main(String... args) { System.exit(0); }}

class Main { public static void main(String... args) { }}

class Main { static int status = 0;

public static void main(String... args) { System.exit(status); }}

master topic

Page 52: Git Introduction Tutorial

basics stages branch merge remotes advanced

class Main { public static void main(String... args) { System.exit(0); }}

class Main { public static void main(String... args) { }}

class Main { static int status = 0;

public static void main(String... args) { System.exit(status); }}

class Main { static int status = 0;

public static void main(String... args) {<<<<<<< HEAD System.exit(0);======= System.exit(status);>>>>>>> topic }}

master topic

Page 53: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 54: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

develop

topic (features)

Page 55: Git Introduction Tutorial

basics stages branch remotes advanced

master

merge

Page 56: Git Introduction Tutorial

basics stages branch remotes advanced

git branch develop

master

develop

merge

Page 57: Git Introduction Tutorial

basics stages branch remotes advanced

master

develop

merge

Page 58: Git Introduction Tutorial

basics stages branch remotes advanced

master

develop

merge

Page 59: Git Introduction Tutorial

basics stages branch remotes advanced

master

develop

feature

git branch featureX

merge

Page 60: Git Introduction Tutorial

basics stages branch remotes advanced

master

develop

feature

feature

git branch featureY

merge

Page 61: Git Introduction Tutorial

basics stages branch remotes advanced

master

develop

feature

feature

git branch featureY

merge

Page 62: Git Introduction Tutorial

basics stages branch remotes advanced

master

develop

feature

feature

git merge featureX

merge

Page 63: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

develop

feature

feature

git merge develop

Page 64: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

develop

feature

feature

version 1.0

Page 65: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

develop

feature

feature

git merge develop

downmerge

Page 66: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

develop

feature

feature

version 2.0

Page 67: Git Introduction Tutorial

basics stages branch merge remotes advanced

master

develop

feature

feature

Page 68: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 69: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory

staging area

repository

Page 70: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory

staging area

local repository

remote repository

Page 71: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory

staging area

local repository

remote repository

working directory

staging area

local repository

working directory

staging area

local repository

developer developer developer

Page 72: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory

staging area

local repository

remote repository

working directory

staging area

local repository

working directory

staging area

local repository

developer developer developer

origin

Page 73: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory staging area local repository remote repository

Page 74: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory staging area local repository remote repository

git add/mv/rm

git commit

git commit -a

git reset <file>

git checkout <branch>

Page 75: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory staging area local repository remote repository

git push

git add/mv/rm

git commit

git commit -a

git reset <file>

git checkout <branch>

Page 76: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory staging area local repository remote repository

git push

git fetch

git add/mv/rm

git commit

git commit -a

git reset <file>

git checkout <branch>

Page 77: Git Introduction Tutorial

basics stages branch merge remotes advanced

working directory staging area local repository remote repository

git push

git fetch

git pull

git add/mv/rm

git commit

git commit -a

git reset <file>

git checkout <branch>

Page 78: Git Introduction Tutorial

basics stages branch merge remotes advanced

Subversion

workingdirectory

Page 79: Git Introduction Tutorial

basics stages branch merge remotes advanced

Subversion

workingdirectory

remoterepository

Page 80: Git Introduction Tutorial

basics stages branch merge remotes advanced

commit

Subversion

workingdirectory

remoterepository

Page 81: Git Introduction Tutorial

basics stages branch merge remotes advanced

updatecommit

Subversion

workingdirectory

remoterepository

Page 82: Git Introduction Tutorial

basics stages branch merge remotes advanced

updatecommit

workingdirectory

Subversion Git

workingdirectory

remoterepository

Page 83: Git Introduction Tutorial

basics stages branch merge remotes advanced

updatecommitlocalrepository

workingdirectory

Subversion Git

workingdirectory

remoterepository

Page 84: Git Introduction Tutorial

basics stages branch merge remotes advanced

updatecommitlocalrepository

workingdirectory

remoterepository

Subversion Git

workingdirectory

remoterepository

Page 85: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Page 86: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Centralized workflow

origin

Page 87: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Centralized workflow

origin

GitHub Forking/Pull Request

dictator

Page 88: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Centralized workflow

origin

GitHub Forking/Pull Request

upstream

dictator developers

fork

origin

Page 89: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Centralized workflow

origin

GitHub Forking/Pull Request

upstream

dictator developers

fork

origin

Page 90: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Centralized workflow

origin

GitHub Forking/Pull Request

Pull request

upstream

dictator developers

origin

fork

Page 91: Git Introduction Tutorial

basics stages branch merge remotes advanced

Distribution models

Centralized workflow

origin

GitHub Forking/Pull Request

Pull request

upstream

dictator developers

origin

fork

Many others

Page 92: Git Introduction Tutorial

basics stages branch merge remotes advanced

Managing remotes

$ git remote -vorigin [email protected]:thrau/openengsb-framework.git (fetch)origin [email protected]:thrau/openengsb-framework.git (push)upstream [email protected]:openengsb/openengsb-framework.git (fetch)upstream [email protected]:openengsb/openengsb-framework.git (push)

$ git remote add <name> <url>

$ git remote rm <name>

Page 93: Git Introduction Tutorial

basics stages branch merge remotes advanced

Remote tracking branches

$ git branch -a

Page 94: Git Introduction Tutorial

basics stages branch merge remotes advanced

Remote tracking branches

$ git branch -a* master my-local-feature remotes/origin/master

Page 95: Git Introduction Tutorial

basics stages branch merge remotes advanced

Remote tracking branches

$ git branch -a* master my-local-feature remotes/origin/master

originlocal

mastermaster,

origin/master

Page 96: Git Introduction Tutorial

basics stages branch merge remotes advanced

Remote tracking branches

$ git branch -a* master my-local-feature remotes/origin/master

originlocal

mastermaster,

origin/master

Page 97: Git Introduction Tutorial

basics stages branch merge remotes advanced

Remote tracking branches

$ git branch -a* master my-local-feature remotes/origin/master

master

origin/master

originlocal

master

Page 98: Git Introduction Tutorial

basics stages branch merge remotes advanced

Remote tracking branches

$ git push

master,origin/master

originlocal

master

Page 99: Git Introduction Tutorial

basics stages branch merge remotes advanced

Delete remote branches

$ git push origin :branchname

Page 100: Git Introduction Tutorial

basics stages branch merge remotes advanced

Delete local tracking branches

$ git fetch origin --prune

Page 101: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

Page 102: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin master

Page 103: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin master

master,origin/master

originlocal

master

Page 104: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin masterTo ssh://thomas@localhost/home/thomas/git-remote ! [rejected] HEAD -> master (non-fast-forward)error: failed to push some refs to 'ssh://thomas@localhost/home/thomas/git-remote'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Page 105: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin masterTo ssh://thomas@localhost/home/thomas/git-remote ! [rejected] HEAD -> master (non-fast-forward)error: failed to push some refs to 'ssh://thomas@localhost/home/thomas/git-remote'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$ git pull origin master

Page 106: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin masterTo ssh://thomas@localhost/home/thomas/git-remote ! [rejected] HEAD -> master (non-fast-forward)error: failed to push some refs to 'ssh://thomas@localhost/home/thomas/git-remote'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$ git pull origin master

… fix merge conflicts ...

Page 107: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin masterTo ssh://thomas@localhost/home/thomas/git-remote ! [rejected] HEAD -> master (non-fast-forward)error: failed to push some refs to 'ssh://thomas@localhost/home/thomas/git-remote'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$ git pull origin master

… fix merge conflicts ...

$ git commit -am "Merge remote branch 'master'"$ git push origin master

Page 108: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin masterTo ssh://thomas@localhost/home/thomas/git-remote ! [rejected] HEAD -> master (non-fast-forward)error: failed to push some refs to 'ssh://thomas@localhost/home/thomas/git-remote'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$ git pull origin master

… fix merge conflicts ...

$ git commit -am "Merge remote branch 'develop'"$ git push origin master

Produces amerge commit

Page 109: Git Introduction Tutorial

basics stages branch merge remotes advanced

Dealing with remote conflicts

$ git push origin masterTo ssh://thomas@localhost/home/thomas/git-remote ! [rejected] HEAD -> master (non-fast-forward)error: failed to push some refs to 'ssh://thomas@localhost/home/thomas/git-remote'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

$ git pull --rebase origin master

… fix merge conflicts ...

$ git rebase --continuerepeat

$ git push origin masterRewrites the

history.

Page 110: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 111: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 112: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

Page 113: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 114: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic

master

topic

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 115: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic

“base”

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 116: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic

“base”

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 117: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 118: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 119: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic

“base”

* * **

* new commits

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 120: Git Introduction Tutorial

basics stages branch merge remotes advanced

Rewriting history

master

topic * * **

Avoid changingpublished histories!

$ git rebase master

Rebase the current branch on to the tip of a different one

Page 121: Git Introduction Tutorial

basics stages branch merge remotes advanced

Ups, I forgot something

Page 122: Git Introduction Tutorial

basics stages branch merge remotes advanced

Ups, I forgot something

$ git commit --amend -a

Add all your current changes to the previous commit

Page 123: Git Introduction Tutorial

basics stages branch merge remotes advanced

Ups, I forgot something

$ git commit --amend -a

$ git commit --amend -m "new commit message"

Reword the last commit

Add all your current changes to the previous commit

Page 124: Git Introduction Tutorial

basics stages branch merge remotes advanced

Ups, I forgot something

$ git commit --amend -a

Add all your current changes to the previous commit

$ git commit --amend -m "new commit message"

Reword the last commit

Avoid changingpublished histories!

Page 125: Git Introduction Tutorial

basics stages branch merge remotes advanced

Pushing a rewritten history

$ git push --force origin <branch>

Danger zone! Overwrites the remote history with your local one. Remote commits may get lost!

Page 126: Git Introduction Tutorial

basics stages branch merge remotes advanced

When that merge came in like a wrecking ball

$ git merge --abort

$ git rebase --abort

Abort an initiated merge or rebase

Page 127: Git Introduction Tutorial

basics stages branch merge remotes advanced

Git tag

$ git tag

Show all tags

$ git tag -a v2.0

Tag the current commit with an annotation

Tag (mark) important points in the commit history, e.g. when a working version is released

$ git push origin --tags

Push tags to the remote

Page 128: Git Introduction Tutorial

basics stages branch merge remotes advanced

Ignoring files

Create a file in your repository (and add & commit it) named .gitignore, containing paths and rules that tell git which files to ignore.

# Maven filestarget/bin/

# Eclipse project files.project.classpath.settings

# Mac OS.DS_Store

# IntelliJ IDEA files*.iml*.ipr*.iws.idea

# backup-files*~

Page 129: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing good commit messages

Page 130: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

Page 131: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

Page 132: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

Page 133: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

“changes”

Page 134: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

“changes”

“it works!”

Page 135: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

“changes”

“it works!”

“final commit”

Page 136: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

“changes”

“it works!”

“final commit”

“Testing in progress ;-)”

Page 137: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

“changes”

“it works!”

“final commit”

“Testing in progress ;-)”

“TODO: write meaningful commit message”

Page 138: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing *bad* commit messages

”fix”

“:(:(“

“changes”

“it works!”

“final commit”

“Testing in progress ;-)”

“TODO: write meaningful commit message”

“Your commit is writing checks your merge can't cash”

Page 139: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing good commit messages

Write commit messages as if you're giving commands to the codebase

Page 140: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing good commit messages

Write commit messages as if you're giving commands to the codebase

“Add DAO interfaces for Entities“

Page 141: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing good commit messages

Write commit messages as if you're giving commands to the codebase

“Add DAO interfaces for Entities“

“Implement basic version of AddressDAO”

Page 142: Git Introduction Tutorial

basics stages branch merge remotes advanced

Writing good commit messages

Write commit messages as if you're giving commands to the codebase

“Add DAO interfaces for Entities“

“Implement basic version of AddressDAO”

“Fix bug in delete method of UserDAO”

“Move package security to at.ac.tuwien.service”

“Add generated fxml files for UI”

Page 143: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 144: Git Introduction Tutorial

basics stages branch merge remotes advanced

Page 145: Git Introduction Tutorial

Other great tutorials

● Official Git Documentationhttp://git-scm.com/doc

● TryGit – An interactive Git tutorialhttp://try.github.io

● Git Immersionhttp://gitimmersion.com/

● Atlassian Git Tutorialshttps://www.atlassian.com/git

● Git Cheatsheet – Command categorisationhttp://ndpsoftware.com/git-cheatsheet.html

● LearnGitBranchinghttp://pcottle.github.io/learnGitBranching

Page 146: Git Introduction Tutorial

Further reading

● A successful Git branching modelhttp://nvie.com/posts/a-successful-git-branching-model/

● Changing history, or How to Git prettyhttp://justinhileman.info/article/changing-history

● Reset Demystifiedhttp://git-scm.com/blog/2011/07/11/reset.html

● Avoiding Git Disasters: A Gory Storyhttp://randyfay.com/node/89

● A Rebase Workflow for Githttp://randyfay.com/node/91

Page 147: Git Introduction Tutorial

Headache?

Questions?

Page 148: Git Introduction Tutorial

fin

Thanks for listening - Enjoy git!

Feedback [email protected]