Git >= SVN

  • lokal nutzbar
  • X remotes oder zentrales Repo (Github, Gitlab)
  • 1 Nutzer oder viele
  • schneller (Branching)
  • platzsparender
  • Branch enhält komplette History
  • mehr Möglichkeiten (stash, rebase, cherry-pick)
  • einfache Verzeichnisstruktur (.git)

Vorteile

Nachteile

SVN >= Git

  • Subtree auschecken, Git nur das komplette Repo
  • Revisionsnummern?
  • Lernkurve

Git Befehle

# Benutzername (nur Repo)
~# git config user.name Jens Nauber

# Benutzername, Email, Editor (Benutzer-/Systemweit)
~# git config --global user.name Jens Nauber
~# git config --global user.email jens.nauber@slub-dresden.de
~# git config --system core.editor vim
  • <repo>/.git/config – Repo-Einstellungen.
  • ~/.gitconfig – Benutzer-Einstellungen (--global)
  • $(prefix)/etc/gitconfig – Systemweite Einstellungen
[user] 
name = Jens Nauber
email = jens.nauber@slub-dresden.de
[alias]
st = status
co = checkout
br = branch
up = rebase
ci = commit
[core]
editor = vim

Git Befehle

$ git log
$ git log --pretty=oneline --abbrev-commit  # Kurzdarstellung
$ git log -p                                # Patches ausgeben
$ git log -p -2                             # Patches für die letzen 2 Commits ausgeben
$ git log --pretty=format:"%h %s" --graph   # Graph-Anzeige
$ git log --since=2.weeks                   # Commits der letzen 2 Wochen anzeigen

$ git shortlog                              # Zusammenfassung nach Personen

Git Befehle

$ git diff <commit_from> <commit_to>
$ git diff 9a03412 0b4ab87
[user]
name = Jens Nauber
email = jens.nauber@slub-dresden.de
[diff]
external = "/home/jensen/Programme/deltawalker/git-diff"
[merge]
tool = deltawalker
[mergetool  "deltawalker"]
path = '/home/jensen/Programme/deltawalker/git-merge'
cmd = '/home/jensen/Programme/deltawalker/git-merge' "$LOCAL" "$REMOTE" "$BASE" "$MERGED"

~/.gitconfig

$ git diff
diff --git a/controller/src/docs/ui b/controller/src/docs/ui
index 838aa1a..b25c13c 160000
--- a/controller/src/docs/ui
+++ b/controller/src/docs/ui
@@ -1 +1 @@
-Subproject commit 838aa1a8f8151e08ccc42289be16a12b2fbbe107
+Subproject commit b25c13c8fb478cb709c6ed970ce40d65caeb8a3d
$ git config --list
user.name=Jens Nauber
user.email=jens.nauber@slub-dresden.de
diff.external=/home/jensen/Programme/deltawalker/git-diff
merge.tool=deltawalker
mergetool.deltawalker.path='/home/jensen/Programme/deltawalker/git-merge'
mergetool.deltawalker.cmd='/home/jensen/Programme/deltawalker/git-merge' $LOCAL $REMOTE $BASE $MERGED

git config

Git Befehle

$ git stash show stash@{0} -p
diff --git a/config/application.rb b/config/application.rb
index e36df91..666b3db 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -7,6 +7,8 @@ Bundler.require(:default, Rails.env)
 
 module Gitlab
   class Application < Rails::Application
+    config.action_mailer.sendmail_settings = { :arguments => "-i" }
+
$ git stash list
stash@{0}: WIP on (no branch): ba76dbc Version 7.4.0.
stash@{1}: WIP on 7-3-stable: 76eaf55 Use origin to compare so it is not dependent on checking out the branch before.
stash@{2}: WIP on (no branch): ff1633f Bump VERSION to 7.2.1
stash@{3}: WIP on 7-1-stable: facfec4 Merge branch 'patch-release' into '7-1-stable'
$ git stash show
config/application.rb |    2 ++
db/schema.rb          |   87 ++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
2 files changed, 44 insertions(+), 45 deletions(-)
$ git stash apply
config/application.rb |    2 ++
db/schema.rb          |   87 ++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
2 files changed, 44 insertions(+), 45 deletions(-)
$ git stash
Saved working directory and index state \
  "WIP on master: 049d078 added the index file"
HEAD is now at 049d078 added the index file
$ git stash branch experimentalfeature

Git Befehle

$ git submodule add <repository> <path>
$ git submodule add git://github.com/jquery/jquery.git libs/jquery/
$ cat .gitmodules
[submodule "jquery"]
	path = libs/jquery/
	url = git://github.com/jquery/jquery.git
$ git commit -am 'added jquery module'
[master fb9093c] added jquery module
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 libs/jquery/
$ git clone <repo>
$ git submodule init
Submodule 'jquery' (git://github.com/jquery/jquery.git) registered for path 'libs/jquery/'
$ git submodule update
Cloning into 'libs/jquery/'...
remote: Counting objects: 11, done.
$ git clone --recursive <repo>

Git Befehle

$ git clone https://github.com/jnauber/dswarm.git
Cloning into 'dswarm'...

$ git remote
origin
$ git remote -v
origin	https://github.com/jnauber/dswarm.git (fetch)
origin	https://github.com/jnauber/dswarm.git (push)
$ git remote add upstream https://github.com/dswarm/dswarm.git
$ git remote -v
origin	https://github.com/jnauber/dswarm.git (fetch)
origin	https://github.com/jnauber/dswarm.git (push)
upstream    https://github.com/dswarm/dswarm.git (fetch)
upstream    https://github.com/dswarm/dswarm.git (push)
$ git fetch upstream
$ git push upstream build/unstable

Git Befehle

  • erlaubt den Zugriff auf SVN Repositories mit git
  • Migration zu git möglich (relativ aufwendig)

Gitlab & Github & Bitbucket

  • webbasierte Hostingdienste für Repositories
    • zentraler Repo-Server
  • kollaboratives Arbeiten
    • Fork -> Pull-/Merge-Requests
    • Code Reviews
    • Bug & Issue tracking
    • Wikis & einfaches Webseiten-Hosting
    • Social Network
  • Gitlab Community Edition = Open Source
  • Gitlab Enterprise Edition, Github, Bitbucket = kommerziell
    • teils kostenfrei nutzbar

Git UIs & IDE-Integration

  • http://git-scm.com/downloads/guis

  • https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Graphical_Interfaces

SVN / Git

By Jens Nauber

SVN / Git

  • 568

More from Jens Nauber