SlideShare a Scribd company logo
/tutorial/git
Thomas Rausch
thomas.rausch@tuwien.ac.at
Institute for Information Systems
Distributed Systems Group
TU Wien
http://git-scm.com
Of Linus and learning curves
“Linus is a guy who delights in being cruel to people …”
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
Of Linus and learning curves
What you should take from today
What you should take from today
git =
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
$ git config --global user.name "Thomas Rausch"
$ git config --global user.email thomas@rauschig.org
Configure your user
basics stages branch merge remotes advanced
$ git init
Initialized empty Git repository in /home/thomas/git-tutorial/.git/
Initialize an empty repository
$ git clone <repo> [<directory>]
Clone a remote repository
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
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
basics stages branch merge remotes advanced
Commit changes
$ git status
# On branch master
nothing 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
basics stages branch merge remotes advanced
View differences of current unstaged modifications
$ git diff --color
diff --git a/src/Main.java b/src/Main.java
index 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);
}
}
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
#
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 master
nothing to commit (working directory clean)
basics stages branch merge remotes advanced
Viewing the history
$ git log
commit 9c3cb834c43d67cc37b15e74b64dc830c1e78199
Author: Thomas Rausch <thomas@rauschig.org>
Date: Mon Oct 14 00:04:53 2013 +0100
modified readme file
commit d4c59ffd7e676dad6aef2cc244b87e3c579aa904
Author: Thomas Rausch <thomas@rauschig.org>
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 --oneline
9c3cb83 modified readme file
d4c59ff add readme file
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
working directory
basics stages branch merge remotes advanced
working directory
staging area
basics stages branch merge remotes advanced
working directory
staging area
repository
basics stages branch merge remotes advanced
working directory
staging area
repository
git add
basics stages branch merge remotes advanced
working directory
staging area
repository
git add
git commit
basics stages branch merge remotes advanced
working directory
staging area
repository
git commit -a
basics stages branch merge remotes advanced
working directory
staging area
repository
basics stages branch merge remotes advanced
git reset HEAD <file>
working directory
staging area
repository
git reset HEAD <file> git checkout
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
$ git branch
develop
* master
new-feature
List branches
basics stages branch merge remotes advanced
$ git branch
develop
* master
new-feature
List branches
Branch you have
currently
checked out
basics stages branch merge remotes advanced
$ git checkout develop
Switched to branch 'develop'
Change into a branch
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
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
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 topic
into master
basics stages branch merge remotes advanced
master
topic
master
topic
basics stages branch merge remotes advanced
master
topic
master
topic
Fast-forward
topic
basics stages branch merge remotes advanced
master
master, topic
Fast-forward
basics stages branch merge remotes advanced
master
topic
master
topic
basics stages branch merge remotes advanced
master
topic
master
topic
Recursive three-way
basics stages branch merge remotes advanced
master
topic
A merge commit
with 2 parents
Recursive three-way
basics stages branch merge remotes advanced
Conflicts
basics stages branch merge remotes advanced
master
basics stages branch merge remotes advanced
class Main {
public static void main(String... args) {
}
}
master
basics stages branch merge remotes advanced
class Main {
public static void main(String... args) {
}
}
master topic
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
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
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
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
master
develop
topic (features)
basics stages branch remotes advanced
master
merge
basics stages branch remotes advanced
git branch develop
master
develop
merge
basics stages branch remotes advanced
master
develop
merge
basics stages branch remotes advanced
master
develop
merge
basics stages branch remotes advanced
master
develop
feature
git branch featureX
merge
basics stages branch remotes advanced
master
develop
feature
feature
git branch featureY
merge
basics stages branch remotes advanced
master
develop
feature
feature
git branch featureY
merge
basics stages branch remotes advanced
master
develop
feature
feature
git merge featureX
merge
basics stages branch merge remotes advanced
master
develop
feature
feature
git merge develop
basics stages branch merge remotes advanced
master
develop
feature
feature
version 1.0
basics stages branch merge remotes advanced
master
develop
feature
feature
git merge develop
downmerge
basics stages branch merge remotes advanced
master
develop
feature
feature
version 2.0
basics stages branch merge remotes advanced
master
develop
feature
feature
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
working directory
staging area
repository
basics stages branch merge remotes advanced
working directory
staging area
local repository
remote repository
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
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
basics stages branch merge remotes advanced
working directory staging area local repository remote repository
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>
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>
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>
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>
basics stages branch merge remotes advanced
Subversion
working
directory
basics stages branch merge remotes advanced
Subversion
working
directory
remote
repository
basics stages branch merge remotes advanced
commit
Subversion
working
directory
remote
repository
basics stages branch merge remotes advanced
updatecommit
Subversion
working
directory
remote
repository
basics stages branch merge remotes advanced
updatecommit
working
directory
Subversion Git
working
directory
remote
repository
basics stages branch merge remotes advanced
updatecommit
local
repository
working
directory
Subversion Git
working
directory
remote
repository
basics stages branch merge remotes advanced
updatecommit
local
repository
working
directory
remote
repository
Subversion Git
working
directory
remote
repository
basics stages branch merge remotes advanced
Distribution models
basics stages branch merge remotes advanced
Distribution models
Centralized workflow
origin
basics stages branch merge remotes advanced
Distribution models
Centralized workflow
origin
GitHub Forking/Pull Request
dictator
basics stages branch merge remotes advanced
Distribution models
Centralized workflow
origin
GitHub Forking/Pull Request
upstream
dictator developers
fork
origin
basics stages branch merge remotes advanced
Distribution models
Centralized workflow
origin
GitHub Forking/Pull Request
upstream
dictator developers
fork
origin
basics stages branch merge remotes advanced
Distribution models
Centralized workflow
origin
GitHub Forking/Pull Request
Pull request
upstream
dictator developers
origin
fork
basics stages branch merge remotes advanced
Distribution models
Centralized workflow
origin
GitHub Forking/Pull Request
Pull request
upstream
dictator developers
origin
fork
Many others
basics stages branch merge remotes advanced
Managing remotes
$ git remote -v
origin git@github.com:thrau/openengsb-framework.git (fetch)
origin git@github.com:thrau/openengsb-framework.git (push)
upstream git@github.com:openengsb/openengsb-framework.git (fetch)
upstream git@github.com:openengsb/openengsb-framework.git (push)
$ git remote add <name> <url>
$ git remote rm <name>
basics stages branch merge remotes advanced
Remote tracking branches
$ git branch -a
basics stages branch merge remotes advanced
Remote tracking branches
$ git branch -a
* master
my-local-feature
remotes/origin/master
basics stages branch merge remotes advanced
Remote tracking branches
$ git branch -a
* master
my-local-feature
remotes/origin/master
originlocal
master
master,
origin/master
basics stages branch merge remotes advanced
Remote tracking branches
$ git branch -a
* master
my-local-feature
remotes/origin/master
originlocal
master
master,
origin/master
basics stages branch merge remotes advanced
Remote tracking branches
$ git branch -a
* master
my-local-feature
remotes/origin/master
master
origin/master
originlocal
master
basics stages branch merge remotes advanced
Remote tracking branches
$ git push
master,
origin/master
originlocal
master
basics stages branch merge remotes advanced
Delete remote branches
$ git push origin :branchname
basics stages branch merge remotes advanced
Delete local tracking branches
$ git fetch origin --prune
basics stages branch merge remotes advanced
Dealing with remote conflicts
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
master,
origin/master
originlocal
master
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
To 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 behind
hint: 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.
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
To 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 behind
hint: 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
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
To 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 behind
hint: 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 ...
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
To 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 behind
hint: 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
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
To 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 behind
hint: 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 a
merge commit
basics stages branch merge remotes advanced
Dealing with remote conflicts
$ git push origin master
To 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 behind
hint: 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 --continue
repeat
$ git push origin master
Rewrites the
history.
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
Rewriting history
basics stages branch merge remotes advanced
Rewriting history
$ git rebase master
Rebase the current branch on to the tip of a different one
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
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
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
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
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
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
basics stages branch merge remotes advanced
Rewriting history
master
topic * * **
Avoid changing
published histories!
$ git rebase master
Rebase the current branch on to the tip of a different one
basics stages branch merge remotes advanced
Ups, I forgot something
basics stages branch merge remotes advanced
Ups, I forgot something
$ git commit --amend -a
Add all your current changes to the previous commit
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
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 changing
published histories!
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!
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
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
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 files
target/
bin/
# Eclipse project files
.project
.classpath
.settings
# Mac OS
.DS_Store
# IntelliJ IDEA files
*.iml
*.ipr
*.iws
.idea
# backup-files
*~
basics stages branch merge remotes advanced
Writing good commit messages
basics stages branch merge remotes advanced
Writing *bad* commit messages
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
“:(:(“
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
“:(:(“
“changes”
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
“:(:(“
“changes”
“it works!”
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
“:(:(“
“changes”
“it works!”
“final commit”
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
“:(:(“
“changes”
“it works!”
“final commit”
“Testing in progress ;-)”
basics stages branch merge remotes advanced
Writing *bad* commit messages
”fix”
“:(:(“
“changes”
“it works!”
“final commit”
“Testing in progress ;-)”
“TODO: write meaningful commit message”
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”
basics stages branch merge remotes advanced
Writing good commit messages
Write commit messages as if you're giving commands to the codebase
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“
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”
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”
basics stages branch merge remotes advanced
basics stages branch merge remotes advanced
Other great tutorials
●
Official Git Documentation
http://git-scm.com/doc
●
TryGit – An interactive Git tutorial
http://try.github.io
●
Git Immersion
http://gitimmersion.com/
●
Atlassian Git Tutorials
https://www.atlassian.com/git
●
Git Cheatsheet – Command categorisation
http://ndpsoftware.com/git-cheatsheet.html
●
LearnGitBranching
http://pcottle.github.io/learnGitBranching
Further reading
●
A successful Git branching model
http://nvie.com/posts/a-successful-git-branching-model/
●
Changing history, or How to Git pretty
http://justinhileman.info/article/changing-history
●
Reset Demystified
http://git-scm.com/blog/2011/07/11/reset.html
●
Avoiding Git Disasters: A Gory Story
http://randyfay.com/node/89
●
A Rebase Workflow for Git
http://randyfay.com/node/91
Headache?
Questions?
fin
Thanks for listening - Enjoy git!
Feedback appreciated
thomas.rausch@tuwien.ac.at

More Related Content

What's hot

Git real slides
Git real slidesGit real slides
Git real slides
Lucas Couto
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Introduction git
Introduction gitIntroduction git
Introduction git
Dian Sigit Prastowo
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
Fran García
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Git workflows presentation
Git workflows presentationGit workflows presentation
Git workflows presentation
Mack Hardy
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Pham Quy (Jack)
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
 
Git
GitGit
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
David Paluy
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
Dilum Navanjana
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
jstack
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
Yash
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Yan Vugenfirer
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 

What's hot (20)

Git real slides
Git real slidesGit real slides
Git real slides
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git workflows presentation
Git workflows presentationGit workflows presentation
Git workflows presentation
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git
GitGit
Git
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 

Similar to Git Introduction Tutorial

Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
Brian K. Vagnini
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
vimukthirandika
 
git - the basics
git - the basicsgit - the basics
git - the basics
Arnelle Balane
 
Using Git as your VCS with Bioconductor
Using Git as your VCS with BioconductorUsing Git as your VCS with Bioconductor
Using Git as your VCS with Bioconductor
timyates
 
Take the next step with git
Take the next step with gitTake the next step with git
Take the next step with git
Karin Taliga
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
Luis Lamadrid
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
Git
GitGit
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Jose Emilio Labra Gayo
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-it
Automat-IT
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
srinathcox
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Arpit Mohan
 
Loading...git
Loading...gitLoading...git
Loading...git
Rafael García
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
Forest Mars
 
Git
GitGit
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
Marco De Stefano
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
Raja Soundaramourty
 
Git
GitGit
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 

Similar to Git Introduction Tutorial (20)

Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
git - the basics
git - the basicsgit - the basics
git - the basics
 
Using Git as your VCS with Bioconductor
Using Git as your VCS with BioconductorUsing Git as your VCS with Bioconductor
Using Git as your VCS with Bioconductor
 
Take the next step with git
Take the next step with gitTake the next step with git
Take the next step with git
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Git
GitGit
Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-it
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Loading...git
Loading...gitLoading...git
Loading...git
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Git
GitGit
Git
 
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Git
GitGit
Git
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
 

More from Thomas Rausch

Test cloud application deployments locally and in CI without staging environm...
Test cloud application deployments locally and in CI without staging environm...Test cloud application deployments locally and in CI without staging environm...
Test cloud application deployments locally and in CI without staging environm...
Thomas Rausch
 
Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...
Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...
Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...
Thomas Rausch
 
Towards a Serverless Platform for Edge AI
Towards a Serverless Platform for Edge AITowards a Serverless Platform for Edge AI
Towards a Serverless Platform for Edge AI
Thomas Rausch
 
Edge Intelligence: The Convergence of Humans, Things and AI
Edge Intelligence: The Convergence of Humans, Things and AIEdge Intelligence: The Convergence of Humans, Things and AI
Edge Intelligence: The Convergence of Humans, Things and AI
Thomas Rausch
 
Portable Energy-Aware Cluster-Based Edge Computers
Portable Energy-Aware Cluster-Based Edge ComputersPortable Energy-Aware Cluster-Based Edge Computers
Portable Energy-Aware Cluster-Based Edge Computers
Thomas Rausch
 
EMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing Applications
EMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing ApplicationsEMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing Applications
EMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing Applications
Thomas Rausch
 
Message-Oriented Middleware for Edge Computing Applications
Message-Oriented Middleware for Edge Computing ApplicationsMessage-Oriented Middleware for Edge Computing Applications
Message-Oriented Middleware for Edge Computing Applications
Thomas Rausch
 
An Empirical Analysis of Build Failures in the Continuous Integration Workflo...
An Empirical Analysis of Build Failures in the Continuous Integration Workflo...An Empirical Analysis of Build Failures in the Continuous Integration Workflo...
An Empirical Analysis of Build Failures in the Continuous Integration Workflo...
Thomas Rausch
 
Build Failure Prediction in Continuous Integration Workflows
Build Failure Prediction in Continuous Integration WorkflowsBuild Failure Prediction in Continuous Integration Workflows
Build Failure Prediction in Continuous Integration Workflows
Thomas Rausch
 

More from Thomas Rausch (9)

Test cloud application deployments locally and in CI without staging environm...
Test cloud application deployments locally and in CI without staging environm...Test cloud application deployments locally and in CI without staging environm...
Test cloud application deployments locally and in CI without staging environm...
 
Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...
Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...
Synthesizing Plausible Infrastructure Configurations for Evaluating Edge Comp...
 
Towards a Serverless Platform for Edge AI
Towards a Serverless Platform for Edge AITowards a Serverless Platform for Edge AI
Towards a Serverless Platform for Edge AI
 
Edge Intelligence: The Convergence of Humans, Things and AI
Edge Intelligence: The Convergence of Humans, Things and AIEdge Intelligence: The Convergence of Humans, Things and AI
Edge Intelligence: The Convergence of Humans, Things and AI
 
Portable Energy-Aware Cluster-Based Edge Computers
Portable Energy-Aware Cluster-Based Edge ComputersPortable Energy-Aware Cluster-Based Edge Computers
Portable Energy-Aware Cluster-Based Edge Computers
 
EMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing Applications
EMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing ApplicationsEMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing Applications
EMMA: Distributed QoS-Aware MQTT Middleware for Edge Computing Applications
 
Message-Oriented Middleware for Edge Computing Applications
Message-Oriented Middleware for Edge Computing ApplicationsMessage-Oriented Middleware for Edge Computing Applications
Message-Oriented Middleware for Edge Computing Applications
 
An Empirical Analysis of Build Failures in the Continuous Integration Workflo...
An Empirical Analysis of Build Failures in the Continuous Integration Workflo...An Empirical Analysis of Build Failures in the Continuous Integration Workflo...
An Empirical Analysis of Build Failures in the Continuous Integration Workflo...
 
Build Failure Prediction in Continuous Integration Workflows
Build Failure Prediction in Continuous Integration WorkflowsBuild Failure Prediction in Continuous Integration Workflows
Build Failure Prediction in Continuous Integration Workflows
 

Recently uploaded

Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
shanihomely
 
Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech
 
ThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and DjangoThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and Django
akshesh doshi
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
kalichargn70th171
 
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDSAmadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
aadhiyaeliza
 
bangalore Girls call 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
bangalore Girls call  👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Deliverybangalore Girls call  👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
bangalore Girls call 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
sunilverma7884
 
GT degree offer diploma Transcript
GT degree offer diploma TranscriptGT degree offer diploma Transcript
GT degree offer diploma Transcript
attueb
 
TEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with YouTEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with You
marcofolio
 
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docxComprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Aardwolf Security
 
當測試開始左移
當測試開始左移當測試開始左移
當測試開始左移
Jersey (CHE-PING) Su
 
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
singhlata50dh
 
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
jealousviolet
 
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to KnowThe Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
onemonitarsoftware
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
SimonedeGijt
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
bhumivarma35300
 
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
OnePlan Solutions
 
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
dream girl
 
Artificial intelligence in customer services or chatbots
Artificial intelligence  in customer services or chatbotsArtificial intelligence  in customer services or chatbots
Artificial intelligence in customer services or chatbots
kayash1656
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
confluent
 
NYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction InnovationNYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction Innovation
NYGGS Construction ERP Software
 

Recently uploaded (20)

Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
 
Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.Mobile App Development Company in Noida - Drona Infotech.
Mobile App Development Company in Noida - Drona Infotech.
 
ThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and DjangoThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and Django
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
 
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDSAmadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
 
bangalore Girls call 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
bangalore Girls call  👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Deliverybangalore Girls call  👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
bangalore Girls call 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
 
GT degree offer diploma Transcript
GT degree offer diploma TranscriptGT degree offer diploma Transcript
GT degree offer diploma Transcript
 
TEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with YouTEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with You
 
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docxComprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
 
當測試開始左移
當測試開始左移當測試開始左移
當測試開始左移
 
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
 
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
VVIP Girls Call Mumbai 9910780858 Provide Best And Top Girl Service And No1 i...
 
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to KnowThe Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
 
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
 
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
 
Artificial intelligence in customer services or chatbots
Artificial intelligence  in customer services or chatbotsArtificial intelligence  in customer services or chatbots
Artificial intelligence in customer services or chatbots
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
 
NYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction InnovationNYGGS 360: A Complete ERP for Construction Innovation
NYGGS 360: A Complete ERP for Construction Innovation
 

Git Introduction Tutorial

  • 1. /tutorial/git Thomas Rausch thomas.rausch@tuwien.ac.at Institute for Information Systems Distributed Systems Group TU Wien
  • 3. Of Linus and learning curves “Linus is a guy who delights in being cruel to people …”
  • 4. 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
  • 5. Of Linus and learning curves
  • 6. What you should take from today
  • 7. What you should take from today git =
  • 8. basics stages branch merge remotes advanced
  • 9. basics stages branch merge remotes advanced
  • 10. basics stages branch merge remotes advanced $ git config --global user.name "Thomas Rausch" $ git config --global user.email thomas@rauschig.org Configure your user
  • 11. basics stages branch merge remotes advanced $ git init Initialized empty Git repository in /home/thomas/git-tutorial/.git/ Initialize an empty repository $ git clone <repo> [<directory>] Clone a remote repository
  • 12. 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
  • 13. 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
  • 14. basics stages branch merge remotes advanced Commit changes $ git status # On branch master nothing 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
  • 15. basics stages branch merge remotes advanced View differences of current unstaged modifications $ git diff --color diff --git a/src/Main.java b/src/Main.java index 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); } }
  • 16. 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 #
  • 17. 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 master nothing to commit (working directory clean)
  • 18. basics stages branch merge remotes advanced Viewing the history $ git log commit 9c3cb834c43d67cc37b15e74b64dc830c1e78199 Author: Thomas Rausch <thomas@rauschig.org> Date: Mon Oct 14 00:04:53 2013 +0100 modified readme file commit d4c59ffd7e676dad6aef2cc244b87e3c579aa904 Author: Thomas Rausch <thomas@rauschig.org> 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 --oneline 9c3cb83 modified readme file d4c59ff add readme file
  • 19. basics stages branch merge remotes advanced
  • 20. basics stages branch merge remotes advanced
  • 21. working directory basics stages branch merge remotes advanced
  • 22. working directory staging area basics stages branch merge remotes advanced
  • 23. working directory staging area repository basics stages branch merge remotes advanced
  • 24. working directory staging area repository git add basics stages branch merge remotes advanced
  • 25. working directory staging area repository git add git commit basics stages branch merge remotes advanced
  • 26. working directory staging area repository git commit -a basics stages branch merge remotes advanced
  • 27. working directory staging area repository basics stages branch merge remotes advanced git reset HEAD <file>
  • 28. working directory staging area repository git reset HEAD <file> git checkout basics stages branch merge remotes advanced
  • 29. basics stages branch merge remotes advanced
  • 30. basics stages branch merge remotes advanced
  • 31. basics stages branch merge remotes advanced
  • 32. basics stages branch merge remotes advanced $ git branch develop * master new-feature List branches
  • 33. basics stages branch merge remotes advanced $ git branch develop * master new-feature List branches Branch you have currently checked out
  • 34. basics stages branch merge remotes advanced $ git checkout develop Switched to branch 'develop' Change into a branch
  • 35. 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
  • 36. basics stages branch merge remotes advanced
  • 37. basics stages branch merge remotes advanced
  • 38. basics stages branch merge remotes advanced
  • 39. 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 topic into master
  • 40. basics stages branch merge remotes advanced master topic master topic
  • 41. basics stages branch merge remotes advanced master topic master topic Fast-forward
  • 42. topic basics stages branch merge remotes advanced master master, topic Fast-forward
  • 43. basics stages branch merge remotes advanced master topic master topic
  • 44. basics stages branch merge remotes advanced master topic master topic Recursive three-way
  • 45. basics stages branch merge remotes advanced master topic A merge commit with 2 parents Recursive three-way
  • 46. basics stages branch merge remotes advanced Conflicts
  • 47. basics stages branch merge remotes advanced master
  • 48. basics stages branch merge remotes advanced class Main { public static void main(String... args) { } } master
  • 49. basics stages branch merge remotes advanced class Main { public static void main(String... args) { } } master topic
  • 50. 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
  • 51. 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
  • 52. 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
  • 53. basics stages branch merge remotes advanced
  • 54. basics stages branch merge remotes advanced master develop topic (features)
  • 55. basics stages branch remotes advanced master merge
  • 56. basics stages branch remotes advanced git branch develop master develop merge
  • 57. basics stages branch remotes advanced master develop merge
  • 58. basics stages branch remotes advanced master develop merge
  • 59. basics stages branch remotes advanced master develop feature git branch featureX merge
  • 60. basics stages branch remotes advanced master develop feature feature git branch featureY merge
  • 61. basics stages branch remotes advanced master develop feature feature git branch featureY merge
  • 62. basics stages branch remotes advanced master develop feature feature git merge featureX merge
  • 63. basics stages branch merge remotes advanced master develop feature feature git merge develop
  • 64. basics stages branch merge remotes advanced master develop feature feature version 1.0
  • 65. basics stages branch merge remotes advanced master develop feature feature git merge develop downmerge
  • 66. basics stages branch merge remotes advanced master develop feature feature version 2.0
  • 67. basics stages branch merge remotes advanced master develop feature feature
  • 68. basics stages branch merge remotes advanced
  • 69. basics stages branch merge remotes advanced working directory staging area repository
  • 70. basics stages branch merge remotes advanced working directory staging area local repository remote repository
  • 71. 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
  • 72. 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
  • 73. basics stages branch merge remotes advanced working directory staging area local repository remote repository
  • 74. 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>
  • 75. 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>
  • 76. 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>
  • 77. 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>
  • 78. basics stages branch merge remotes advanced Subversion working directory
  • 79. basics stages branch merge remotes advanced Subversion working directory remote repository
  • 80. basics stages branch merge remotes advanced commit Subversion working directory remote repository
  • 81. basics stages branch merge remotes advanced updatecommit Subversion working directory remote repository
  • 82. basics stages branch merge remotes advanced updatecommit working directory Subversion Git working directory remote repository
  • 83. basics stages branch merge remotes advanced updatecommit local repository working directory Subversion Git working directory remote repository
  • 84. basics stages branch merge remotes advanced updatecommit local repository working directory remote repository Subversion Git working directory remote repository
  • 85. basics stages branch merge remotes advanced Distribution models
  • 86. basics stages branch merge remotes advanced Distribution models Centralized workflow origin
  • 87. basics stages branch merge remotes advanced Distribution models Centralized workflow origin GitHub Forking/Pull Request dictator
  • 88. basics stages branch merge remotes advanced Distribution models Centralized workflow origin GitHub Forking/Pull Request upstream dictator developers fork origin
  • 89. basics stages branch merge remotes advanced Distribution models Centralized workflow origin GitHub Forking/Pull Request upstream dictator developers fork origin
  • 90. basics stages branch merge remotes advanced Distribution models Centralized workflow origin GitHub Forking/Pull Request Pull request upstream dictator developers origin fork
  • 91. basics stages branch merge remotes advanced Distribution models Centralized workflow origin GitHub Forking/Pull Request Pull request upstream dictator developers origin fork Many others
  • 92. basics stages branch merge remotes advanced Managing remotes $ git remote -v origin git@github.com:thrau/openengsb-framework.git (fetch) origin git@github.com:thrau/openengsb-framework.git (push) upstream git@github.com:openengsb/openengsb-framework.git (fetch) upstream git@github.com:openengsb/openengsb-framework.git (push) $ git remote add <name> <url> $ git remote rm <name>
  • 93. basics stages branch merge remotes advanced Remote tracking branches $ git branch -a
  • 94. basics stages branch merge remotes advanced Remote tracking branches $ git branch -a * master my-local-feature remotes/origin/master
  • 95. basics stages branch merge remotes advanced Remote tracking branches $ git branch -a * master my-local-feature remotes/origin/master originlocal master master, origin/master
  • 96. basics stages branch merge remotes advanced Remote tracking branches $ git branch -a * master my-local-feature remotes/origin/master originlocal master master, origin/master
  • 97. basics stages branch merge remotes advanced Remote tracking branches $ git branch -a * master my-local-feature remotes/origin/master master origin/master originlocal master
  • 98. basics stages branch merge remotes advanced Remote tracking branches $ git push master, origin/master originlocal master
  • 99. basics stages branch merge remotes advanced Delete remote branches $ git push origin :branchname
  • 100. basics stages branch merge remotes advanced Delete local tracking branches $ git fetch origin --prune
  • 101. basics stages branch merge remotes advanced Dealing with remote conflicts
  • 102. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master
  • 103. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master master, origin/master originlocal master
  • 104. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master To 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 behind hint: 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.
  • 105. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master To 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 behind hint: 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
  • 106. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master To 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 behind hint: 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 ...
  • 107. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master To 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 behind hint: 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
  • 108. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master To 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 behind hint: 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 a merge commit
  • 109. basics stages branch merge remotes advanced Dealing with remote conflicts $ git push origin master To 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 behind hint: 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 --continue repeat $ git push origin master Rewrites the history.
  • 110. basics stages branch merge remotes advanced
  • 111. basics stages branch merge remotes advanced
  • 112. basics stages branch merge remotes advanced Rewriting history
  • 113. basics stages branch merge remotes advanced Rewriting history $ git rebase master Rebase the current branch on to the tip of a different one
  • 114. 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
  • 115. 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
  • 116. 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
  • 117. 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
  • 118. 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
  • 119. 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
  • 120. basics stages branch merge remotes advanced Rewriting history master topic * * ** Avoid changing published histories! $ git rebase master Rebase the current branch on to the tip of a different one
  • 121. basics stages branch merge remotes advanced Ups, I forgot something
  • 122. basics stages branch merge remotes advanced Ups, I forgot something $ git commit --amend -a Add all your current changes to the previous commit
  • 123. 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
  • 124. 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 changing published histories!
  • 125. 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!
  • 126. 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
  • 127. 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
  • 128. 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 files target/ bin/ # Eclipse project files .project .classpath .settings # Mac OS .DS_Store # IntelliJ IDEA files *.iml *.ipr *.iws .idea # backup-files *~
  • 129. basics stages branch merge remotes advanced Writing good commit messages
  • 130. basics stages branch merge remotes advanced Writing *bad* commit messages
  • 131. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix”
  • 132. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix” “:(:(“
  • 133. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix” “:(:(“ “changes”
  • 134. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix” “:(:(“ “changes” “it works!”
  • 135. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix” “:(:(“ “changes” “it works!” “final commit”
  • 136. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix” “:(:(“ “changes” “it works!” “final commit” “Testing in progress ;-)”
  • 137. basics stages branch merge remotes advanced Writing *bad* commit messages ”fix” “:(:(“ “changes” “it works!” “final commit” “Testing in progress ;-)” “TODO: write meaningful commit message”
  • 138. 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”
  • 139. basics stages branch merge remotes advanced Writing good commit messages Write commit messages as if you're giving commands to the codebase
  • 140. 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“
  • 141. 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”
  • 142. 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”
  • 143. basics stages branch merge remotes advanced
  • 144. basics stages branch merge remotes advanced
  • 145. Other great tutorials ● Official Git Documentation http://git-scm.com/doc ● TryGit – An interactive Git tutorial http://try.github.io ● Git Immersion http://gitimmersion.com/ ● Atlassian Git Tutorials https://www.atlassian.com/git ● Git Cheatsheet – Command categorisation http://ndpsoftware.com/git-cheatsheet.html ● LearnGitBranching http://pcottle.github.io/learnGitBranching
  • 146. Further reading ● A successful Git branching model http://nvie.com/posts/a-successful-git-branching-model/ ● Changing history, or How to Git pretty http://justinhileman.info/article/changing-history ● Reset Demystified http://git-scm.com/blog/2011/07/11/reset.html ● Avoiding Git Disasters: A Gory Story http://randyfay.com/node/89 ● A Rebase Workflow for Git http://randyfay.com/node/91
  • 148. fin Thanks for listening - Enjoy git! Feedback appreciated thomas.rausch@tuwien.ac.at