Skip to content

Instantly share code, notes, and snippets.

@sim51
Last active August 29, 2015 14:04
Show Gist options
  • Save sim51/3d93cb244182019c09d9 to your computer and use it in GitHub Desktop.
Save sim51/3d93cb244182019c09d9 to your computer and use it in GitHub Desktop.
Formation GIT#hype
@charset "UTF-8";
/* =============================================================================== */
/* COMMON STYLE
/* =============================================================================== */
body {
background: #FFFFFF;
color : #556F7C;
}
.reveal pre.unstyled {
box-shadow: none;
}
.reveal {
color : #556F7C;
}
.reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal a {
color: #E85D1A;
}
.reveal h1 { font-size: 2.5em; text-transform: none;}
.reveal h1.title { font-size: 3.77em; }
.reveal a:hover {
font-weight : bold;
color: #E85D1A;
}
.reveal .controls div.navigate-right, .reveal .controls div.navigate-right.enabled, .reveal .controls div.navigate-right.enabled:hover {
color: #E85D1A;
border-left-color: #E85D1A;
}
.reveal .controls div.navigate-right.enabled:hover {
opacity: 0.9;
}
.reveal .controls div.navigate-left, .reveal .controls div.navigate-left.enabled, .reveal .controls div.navigate-left.enabled:hover{
color: #E85D1A;
border-right-color: #E85D1A;
}
.reveal .controls div.navigate-left.enabled:hover {
opacity: 0.9;
}
.reveal .controls div.navigate-up, .reveal .controls div.navigate-up.enabled, .reveal .controls div.navigate-up.enabled:hover {
color: #E85D1A;
border-bottom-color: #E85D1A;
}
.reveal .controls div.navigate-up.enabled:hover {
opacity: 0.9;
}
.reveal .controls div.navigate-down, .reveal .controls div.navigate-down.enabled, .reveal .controls div.navigate-down.enabled:hover {
color: #E85D1A;
border-top-color: #E85D1A;
}
.reveal .controls div.navigate-down.enabled:hover {
opacity: 0.9;
}
.reveal .progress span {
background-color: #E85D1A;
}
.reveal section img {
border: none;
box-shadow: none;
}
.reveal section ul {
list-style-type: square;
}
/* =============================================================================== */
.background-image {
position: absolute;
bottom: -200px;
right: -200px;
opacity: 0.4;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Formation GIT</title>
<meta name="description" content="Formation GIT">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="http://lab.hakim.se/reveal-js/css/reveal.min.css">
<link rel="stylesheet" href="http://lab.hakim.se/reveal-js/css/theme/default.css" id="theme">
<link rel="Stylesheet" href="https://rawgit.com/sim51/3d93cb244182019c09d9/raw/Formation%20GIT.css" />
<!-- For syntax highlighting -->
<link rel="stylesheet" href="http://lab.hakim.se/reveal-js/lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="http://lab.hakim.se/reveal-js/css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- Presentation slide -->
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h1>GIT</h1>
<h3>Enhance your SCM with GIT</h3>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
<p>
<small>By <a href="http://www.bsimard.com">Benoît Simard</a> / <a href="http://twitter.com/logisima">@logisima</a></small>
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://www.byyourcommand.net/CylonCent.png" /></div>
<h2>They have a plan</h2>
<p>History & overview</p>
<p>Installation & configuration</p>
<p>First step</p>
<p>The internal plumbery</p>
<p>Use a remote</p>
<p>Workflow</p>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h2>History & overview</h2>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://cdn1.tnwcdn.com/files/2011/06/Wikipedia-logo.png" /></div>
<h2>Some history</h2>
<p><strong>April 2005 :</strong> created by <a href="">Linus Torvald</a></p>
<p><strong>June 2005 :</strong> First release of linux kernel with GIT</p>
<p><strong>December 2005 :</strong> version 1.0</p>
<p class="fragment"><strong>April 2008 :</strong> <a href="">github</a> is launched</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://gkript.org/images/gnu_logo.png" /></div>
<h2>GNU GPL V2</h2>
<img src="http://geekandpoke.typepad.com/geekandpoke/images/2008/01/17/freebeer.jpg" />
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>GIT is distributed</h3>
<img src="http://upload.wikimedia.org/wikipedia/en/b/ba/Centralised-decentralised-distributed.png" />
<div class="fragment">
<h4>Centralized</h4>
<quote><code>We borrow, and we work on a local working copy</code></quote>
</div>
<div class="fragment">
<h4>Distributed</h4>
<quote><code>We work on a local repository, and we publish on others</code></quote>
</div>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://m7k.org/forums/Smileys/express2/fonz.gif" /></div>
<h3>Cool things</h3>
<p>Full history available locally</p>
<p>No need for network connection for usual operations</p>
</section>
<section>
<div class="background-image"><img src="http://mattandcat.co.uk/reviews/media/blogs/eating/fonzie.gif" /></div>
<h3>But ...</h3>
<p class="fragment">Initial cloning can be long (full history)</p>
<p class="fragment">No lock system (can be a problem for binaries)</p>
</section>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h2>Installation & configuration</h2>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h2>Installation</h2>
<pre><code>
$ apt-get install git meld
</code></pre>
<p class="fragment">Make sure the git command is available in your terminal</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://static.tumblr.com/r2ozdjo/oEhlw46da/t.png" /></div>
<h2>Who you are </h2>
<pre><code>
$ git config --global user.name "Benoît Simard"
$ git config --global user.email "besim@smile.fr"
</code></pre>
<p class="fragment">Make sure the git command is available in your terminal</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="https://anthonylegoff.guru/wp-content/uploads/2014/05/vim_by_liggliluff-d5g1led.png" /></div>
<h2>Setting editors</h2>
<div class="fragment">
<h3>Text editor</h3>
<pre><code>
$ git config --global core.editor vi
$ git config --global core.editor gedit
$ git config --global core.editor subl
</code></pre>
</div>
<div class="fragment">
<h3>Diff editor</h3>
<pre><code>
$ git config --global merge.tool /usr/local/bin/git-diff.sh
$ git config --global diff.external /usr/local/bin/git-diff.sh
</code></pre>
</div>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://cdn.nyanit.com/nyan2.gif" /></div>
<h2>Colorize your terminal</h2>
<pre><code>
$ git config --global color.ui auto
</code></pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://img.gawkerassets.com/img/17vyiytcgue6hpng/original.png" /></div>
<h2>Update your prompt !</h2>
<p>The git package comes with PS1 macro your can add to your prompt. It will display the current branch if your are inside a git repository.
<pre><code>
# Find this line in your .bachrc
if [ "$color_prompt" = yes ]; then
PS1=’${debian_chroot:+($debian_chroot)}\[\033[01;32m\]
\u@\h\[\033[00m\]:\[\033[01;34m\]
\w$(__git_ps1 " (%s)")\[\033[00m\]\$ ’
else
PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ’
fi
unset color_prompt force_color_prompt
</code></pre>
</section>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h2>First step</h2>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Create a Git repo</h3>
<pre><code style="margin-top: 20px;">
$ mkdir hello
$ cd hello
$ git init
</code></pre>
<h3 class="fragment">The actual repo exist in the .git dir</h3>
<pre class="fragment"><code style="margin-top: 20px;">
$ ls -la
$ .git
</code></pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Add a file to be version controlled</h3>
<pre><code style="margin-top: 20px;">
$ echo "Hello" > README
$ git add README
$ git commit -am "Adding README"
</code></pre>
<p class="fragment" style="margin-top:1em;font-size:smaller">Use the <em>-m</em> switch to specify a commit message!</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Create a .gitignore file</h3>
<pre><code style="margin-top: 20px;">
$ echo "/.idea" > .gitignore
$ git add .gitignore
$ git commit -am "Adding gitignore"
</code></pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Edit some more...</h3>
<pre><code>
$ echo "World" >> README
</pre></code>
<h3 class="fragment">...check what has changed...</h3>
<pre class="fragment"><code>
$ git diff
diff --git a/README b/README
index e965047..f9264f7 100644
--- a/README
+++ b/README
@@ -1 +1,2 @@
Hello
+World
</pre></code>
<h3 class="fragment">...and commit it!</h3>
<pre class="fragment"><code>
$ git commit -am "Modified README"
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Make a mistake ...</h3>
<pre><code>
$ > README
</pre></code>
<pre class="fragment"><code>
$ git reset HEAD --hard
</code></pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Study our history</h3>
<pre><code>
$ git log
commit b0b9e95d72c4ba6cae83e5e89050718c4a505037
Author: Benoit Simard &lt;besim@smile.fr&gt;
Date: Thu Jun 28 10:17:26 2014 +0200
Modified README
commit 73aa18e9ccc40c902bc37ff572f8495b6069ebaf
Author: Benoit Simard &lt;besim@smile.fr&gt;
Date: Thu Jun 28 10:12:29 2014 +0200
Adding README
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>A variant of the log output</h3>
<pre><code>
$ git log --oneline
b0b9e95 Modified README
73aa18e Adding README
</pre></code>
<pre><code>
$ git log --graph --pretty=format:'%h - %d %s %cr &lt;%an&gt;' --abbrev-commit --date=relative
* b0b9e95 - (HEAD, master) Modified README 9 minutes ago &lt;Benoît Simard&gt;
* 73aa18e - Adding README 14 minutes ago &lt;Benoît Simard&gt;
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>List existing branches</h3>
<pre><code>
$ git branch
* master
</pre></code>
<p class="fragment">The '*' indicates 'current branch'</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Create a new branch, named 'dev'</h3>
<pre><code>
$ git branch dev
$ git branch
dev
* master
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Make 'dev' the current branch</h3>
<pre><code>
$ git checkout dev
$ git branch
* dev
master
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Create <b>and</b> checkout a new branch</h3>
<pre><code>
$ git checkout -b bugfix
$ git branch
* bugfix
dev
master
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Work in the 'bugfix' branch...</h3>
<pre><code>
$ echo "Blaha" >> README
$ git commit -am "Work in branch"
</pre></code>
<h3 class="fragment">...and merge it to 'master'</h3>
<pre class="fragment"><code>
$ git checkout master
$ git merge --no-ff bugfix # ignore the switch for now...
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Look at the commit graph</h3>
<pre><code>
$ git log --graph --pretty=format:'%h - %d %s %cr;' --abbrev-commit --date=relative
* 5a84ac8 - (HEAD, master) Merge branch 'bugfix' 3 minutes ago
|\
| * f8d890e - (bugfix) Work in branch 3 minutes ago
|/
* b0b9e95 - (dev) Modified README 28 minutes ago
* 73aa18e - Adding README 33 minutes ago
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://primalpiggy.files.wordpress.com/2013/04/bugs-bunny-carrot-icon.png" /></div>
<h3>That's all folks!</h3>
<p style="margin-top:2em;">
You have now seen the basic workflow, which isn't
that different, compared to other VCS you've tried.
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Fast forward</h3>
<p>
A merge results in a merge commit, with two parents, one pointing at each of the two lines of development that were merged. But not in FF mode.
</p>
<img src="http://nvie.com/img/2010/01/merge-without-ff.png" />
</section>
<section>
<h3>Change your last commit</h3>
<pre><code>
$ echo "Hello world" > README
$ git commit README -m "adding world" --amend
</code></pre>
<p class="fragment" style="color:red">
Do not use it when you have already published !
</p>
</section>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h2>The internal plumbery</h2>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
</section>
<section>
<h3>3 type of objects in a repository:</h3>
<ul>
<li class="fragment">blob</li>
<li class="fragment">tree</li>
<li class="fragment">commit</li>
</ul>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>The Blob</h3>
<pre><code>
$ mkdir sample
$ cd sample
$ echo 'Hello, world!' > greeting
$ git hash-object greeting
af5626b4a114abcb82d63db7c8082c3c4756e51b
</pre></code>
<p class="fragment" style="margin-top:2em;font-size:smaller">
The blob (i.e the file content) is stored in a file<br>
with the name made up of the hash of the file content.
</p>
<p class="fragment" style="margin-top:2em;font-size:smaller">
Also, notice how we are using the <em>plumbing</em>
(i.e low-level commands normally named as: xxx-yyy)
commands of git. They are used by the <em>porcelain</em>
commands which the normal user only ever see...
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Blobs are stored in Trees</h3>
<img src="http://www.git-scm.com/figures/18333fig0901-tn.png" />
<pre><code>
# What our (last committed) Tree object contains
$ git ls-tree HEAD
100644 blob af5626b4a114abcb82d63db7c8082c3c4756e51b greeting
</pre></code>
<p class="fragment" style="margin-top:3em;font-size:smaller">
<em>HEAD</em> points to the current checked-out branch
(as will be explained soon...)
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>All are files ...</h3>
<p class="fragment" style="margin-top:2em;font-size:smaller">
What git objects may those files hold?
</p>
<pre class="fragment"><code>
$ for i in `find .git/objects -type f | sort | \
sed -e 's#.git/objects##g' -e 's#/##g'`; \
do echo $i `git cat-file -t $i`; done
9fbac661424a5e1e7fb9c1a6a516b58fc701f2f0 tree
ce013625030ba8dba906f756967f9e9ca394464a blob
ce7199cdfe41e8c6fbf018bdfd8459287962bd5a commit
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Look into that commit object:</h3>
<pre><code>
$ git cat-file commit ce7199cdfe41e8c6fbf018bdfd8459287962bd5a
tree 9fbac661424a5e1e7fb9c1a6a516b58fc701f2f0
author Benoit Simard &lt;besim@smile.fr&gt; 1340820335 +0200
committer Benoit Simard &lt;besim@smile.fr&gt; 1340820335 +0200
Added my greeting
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="https://camo.githubusercontent.com/16363f5e308eae0849b83d183bf4990a25b81ada/68747470733a2f2f7261772e6769746875622e636f6d2f6a6d6376657474612f6e656f69736d2f6d61737465722f6e656f69736d2e706e67" /></div>
<h3>Graph are everywhere !</h3>
<img src="http://www.git-scm.com/figures/18333fig0903-tn.png" />
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Branches</h3>
<p>
A git branch is just a name (label) pointing out a specific
commit object.
</p>
<pre class="fragment"><code>
$ cat .git/refs/heads/master
5a84ac8a2101b740433bcf4b6d805b68d2543a8c
$ cat .git/refs/heads/dev
b0b9e95d72c4ba6cae83e5e89050718c4a505037
# Note how the branch names relates to the commit hashes!
$ git log --graph --pretty=format:'%h - %d %s %cr' --abbrev-commit --date=relative
* 5a84ac8 - (HEAD, master) Merge branch 'bugfix' 2 hours ago
|\
| * f8d890e - (bugfix) Work in branch 2 hours ago
|/
* b0b9e95 - (dev) Modified README 3 hours ago
</pre></code>
<p class="fragment" style="font-size:smaller">
Now, remember where 'master' and 'dev' points in the graph above.
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>An experiment...</h3>
<pre><code>
$ cat .git/refs/heads/master
5a84ac8a2101b740433bcf4b6d805b68d2543a8c
$ cp .git/refs/heads/master .git/refs/heads/dev
$ cat .git/refs/heads/dev
5a84ac8a2101b740433bcf4b6d805b68d2543a8c
</pre></code>
<pre class="fragment"><code>
# The 'dev' branch now points to the same commit hash
# as the master branch, i.e. a 'branch' is just a 'label'
# pointing to a particular commit object.
$ git log <em style="font-size:smaller">--graph --pretty=format:'%h - %d %s %cr' --abbrev-commit --date=relative</em>
* 5a84ac8 - (HEAD, master, dev) Merge branch 'bugfix' 3 hours ago
|\
| * f8d890e - (bugfix) Work in branch 3 hours ago
|/
* b0b9e95 - Modified README 3 hours ago
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>What about <em>HEAD</em> ?</h3>
<pre><code>
$ cat .git/HEAD
ref: refs/heads/master
</pre></code>
<p style="margin-top:1em;font-size:smaller">
<em>HEAD</em> is a pointer to the local branch you are currently on!
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Git Index - the staging area</h3>
<h4 class="fragment">Remember:</h4>
<p class="fragment" style="margin-top:1em;font-size:smaller">
Your repo consist of a graph of commit objects.
</p>
<p class="fragment" style="margin-top:1em;font-size:smaller">
Your 'next' commit object to be, is formed in the
staging area, called:
</p>
<p class="fragment" style="margin-top:1em;font-size:bigger">
The Index
</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>The function of the Index</h3>
<img src="http://git-intro.redhoterlang.org/images/the-index.png">
<p class="fragment" style="margin-top:1em;font-size:smaller">
Use the <em>-a</em> switch to 'bypass' the index (or rather, you'll take all stuff in the index and working dir and commit it in one big swoop).
</p>
</section>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h2>Use a remote</h2>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
</section>
<section>
<img src="http://nvie.com/img/2010/01/centr-decentr.png" />
</section>
<section>
<div class="background-image"><img src="http://subtub.io/OscControllerKit/Presentation/files/img/nintendo_wii_remote.png" /></div>
<h3>A <span style="color:red">remote</span> is an alias for a git URL</h3>
<pre class="fragment"><code>
# Clone and enter a git repo!
$ git clone git://github.com/smile/my-project.git
$ cd my-project/
# Display our remotes
# (origin is the 'default', as setup when cloning)
$ git remote -v show
origin git://github.com/smile/my-project.git (fetch)
origin git://github.com/smile/my-project.git (push)
</pre></code>
<pre class="fragment"><code>
# Add a new remote (alias)!
$ git remote add besim git@github.com:besim/my-project.git
</pre></code>
<pre class="fragment"><code>
$ git remote -v show
origin git://github.com/smile/my-project.git (fetch)
origin git://github.com/smile/my-project.git (push)
besim git@github.com:besim/my-project.git (fetch)
besim git@github.com:besim/my-project.git (push
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<p>Retrieve the content from our new remote repo!</p>
<pre class="fragment"><code>
$ git fetch besim
</pre></code>
<pre class="fragment"><code>
# Note the remote branch names ( &lt;remote&gt;/&lt;branch&gt; )
$ git log --all --graph --pretty=format:'%h - %d %s' --abbrev-commit
* b80a4a9 - (HEAD, besim/master, origin/master, origin/HEAD, master) Search for the qemu binary
* c45b4f2 - Add a target to run the tests
....
</pre></code>
<p class="fragment" style="font-size:smaller">
Remote branches are there for reference.
You always work in a local branch!
</p>
<pre class="fragment"><code>
# Checkout and create a local branch 'foo'
# representing the remote 'besim/master' branch.
$ git checkout -b foo besim/master
</pre></code>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>Push to a remote repo</h3>
<p class="fragment" style="margin-top:1em;font-size:smaller">
git push [&lt;where&gt; [&lt;localbranch&gt;[:&lt;remotebranch&gt;]]
</p>
<pre class="fragment"><code>
# Push to default (tracked!) branch
$ git push
# ...or (as in the previous example):
$ git push besim foo:master
</pre></code>
<pre class="fragment"><code>
# Create a new(!) remote branch (label!) at the remote repo
$ git push besim foo:bar
</pre></code>
<pre class="fragment"><code>
# Remove remote branch
# (Note that we only remove the 'label' !!)
$ git push besim :bar
# Equivalent with the above:
$ git push --delete besim bar
</pre></code>
</section>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<div class="background-image"><img src="http://blog.zedroot.org/content/images/2014/Feb/git_logo.png" /></div>
<h2>Workflow</h2>
<pre class="unstyled">
,---------------.
/ /``````|``````\\
/ /_______|_______\\________
|] GIT |' | |]
= .-:-. |________| .-:-. =
` -+- -------------- -+- '
'-:-' '-:-'
</pre>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<div class="background-image"><img src="http://effectpartners.com/wp-content/uploads/2010/05/tree.png" /></div>
<h3>Use branches</h3>
<p class="fragment">Git branches ares lights</p>
<p class="fragment">You do not have to push all your local branches</p>
<p class="fragment">Git is only a tool ! It does not replace procedures, documentation & communication</p>
</section>
<!-- ------------------------------------------------------------------------------------------------------------------------------- -->
<section>
<h3>GIT FLOW</h3>
<img height="600px" src="http://nvie.com/img/2009/12/Screen-shot-2009-12-24-at-11.32.03.png" />
<p>@See documentation <a href="http://nvie.com/posts/a-successful-git-branching-model/">here</a></p>
</section>
<section>
<h3>Main branches</h3>
<img src="http://nvie.com/img/2009/12/bm002.png" />
</section>
<section>
<h3>Feature branches</h3>
<p>Create a feature branch</p>
<pre><code>
$ git checkout -b myfeature develop
Switched to a new branch "myfeature"
</code></pre>
<p>Incorporating a finished feature on develop</p>
<pre><code>
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).
$ git push origin develop
</code></pre>
</section>
<section>
<h3>Make a release (1)</h3>
<p>Create a branch from the develop</p>
<pre><code>
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2
</code></pre>
</section>
<section>
<h3>Make a release (2)</h3>
<pre><code>
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2
</code></pre>
<pre><code>
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
</code></pre>
</section>
</section>
<!-- ============================================================================================================================== -->
<section>
<section>
<h3>Some final words</h3>
<div class="background-image"><img src="http://www.york-services.com/wp-content/uploads/2379-spiderman.gif" /></div>
<p class="fragment" style="margin-top:2em;font-size:smaller;">
Use <em style="padding:0 10px;color:red;">git stash</em> when you want to record the current state of
the working directory and the index, but want to (quickly) go back
to a clean working directory
</p>
<p class="fragment" style="margin-top:2em;font-size:smaller;">
Use <a href="http://www.youtube.com/embed/uacjFKHmlTg"><em style="padding:0 10px;">git rebase</em></a> to keep your commit graph nice and clean! It makes it possible to rewrite your commit graph in fantastic ways. <em style="font-size:smaller">(with great power, comes ...)</em>
</p>
<p class="fragment" style="margin-top:2em;font-size:smaller;">
Add your favorite <em style="padding:0 10px;color:red;">alias</em>
to your <em>~/.gitconfig</em> file, for example:
</p>
<pre class="fragment"><code>
lol = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Creset' --abbrev-commit --date=relative
lola = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Creset' --abbrev-commit --date=relative --all
dif = difftool --dir-diff
</pre></code>
</section>
<section>
<div class="background-image"><img src="http://geektionnerd.net/wp-content/uploads/2010/12/10-12-30-RTFM-ES-3.png" /></div>
<h3>Documentation</h3>
<p><a href="http://git-scm.com">Official documentation</a></p>
<p><a href="http://nvie.com/posts/a-successful-git-branching-model/">All the workflow documentation</a></p>
<p><a href="http://try.github.io/levels/1/challenges/1">Git in ten minutes</a></p>
<p><a href="http://www.ndpsoftware.com/git-cheatsheet.html">Cheat sheet</a></p>
</section>
</section>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/headjs/0.99/head.min.js"></script>
<script src="http://lab.hakim.se/reveal-js/js/reveal.js"></script>
<script type="text/javascript">
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: false, // don't set to true if you want to edit your prez with hype, because it reload the iframe
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'http://lab.hakim.se/reveal-js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
<!-- DO NOT REMOVE THE LINE ABOVE -->
<!-- ###HYPE_INJECTION_CODE### -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment