Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

basic: commands and slides

  • Loading branch information...
commit 0cd3356fc34fc842590ed2eef203fc64a1de765d 1 parent 75bbbe4
Jeroen authored
46 demo-commands.wiki
View
@@ -9,8 +9,50 @@ git commit
git log
=== part 2 ===
-create another file
-modify 2 files
+# create another file
+echo 'hello' > anotherfile.txt
+# modify 2 files
+vim say-hi.rb
+vim hello.txt
git status
git diff
git add say-hi.rb
+# show the different state
+git status
+# commit the new file but not the modified file
+git commit
+# show this
+git status
+
+# show how to avoid the index
+git commit -a
+
+# show the patch option (first modify the file on two blocks)
+vim hello.txt
+git add -p hello.txt
+? # show the options
+s # split the chunks
+y # add the chunk
+n # ignore the chunk
+git status
+git commit
+git status
+# show that line 2 has not been committed
+git diff
+
+# now show the diff between indexed and not
+git add
+git diff # shows nothing because added to index
+git diff --cached # shows the changes
+# modify the file again to have it twice in the status
+vim hello.txt
+git status # file is twice in status
+
+git commit
+git status # file is still modified
+
+
+# restore modified file to the commited one
+git checkout -- hello.txt
+git status
+vim hello.txt # show the file
25 version-control-with-git.html5.html
View
@@ -459,6 +459,13 @@
<div class="slide">
<header><h1>Version Control with Git</h1></header>
<section class="small">
+
+ </section>
+ </div>
+
+ <div class="slide">
+ <header><h1>Who am I?</h1></header>
+ <section class="small">
<ul>
<li>Jeroen Budts</li>
<li>PHP &amp; Drupal Developer</li>
@@ -542,13 +549,21 @@
</div>
<div class="slide">
- <header><h1>Let's make some more changes</h1></header>
+ <header><h1>The Index (Staging Area)</h1></header>
<section class="small">
- <ul>
-<li>modify some files: <code>vim hello.txt</code></li>
-<li>add it to the index: <code>git add hello.txt</code></li>
-</ul>
+ <p>If you add a file, or a part of a file, to the index, a copy is made of that file. When you commit, it is that copy which ends up in the commit.</p>
+
+<p><strong>Important</strong>: if you make changes to the file after adding it to the index, those changes will
+not end up in your commit, unless you add the file again to the index!</p>
+
+<pre><code>`git diff`
+# shows the diff of your working copy
+
+`git diff --cached`
+# show the diff of your index
+</code></pre>
+<p>Let's make some more changes and add some of these changes to the index.</p>
18 version-control-with-git.markdown
View
@@ -1,6 +1,8 @@
title: Version Control with Git
# Version Control with Git
+
+# Who am I?
* Jeroen Budts
* PHP & Drupal Developer
* At Inuits - A Belgian Open Source Consultancy Company
@@ -38,9 +40,19 @@ The index contains the changes to will be added to your next commit. Your commit
![git-02](img/git-02.png)
-# Let's make some more changes
-* modify some files: `vim hello.txt`
-* add it to the index: `git add hello.txt`
+# The Index (Staging Area)
+If you add a file, or a part of a file, to the index, a copy is made of that file. When you commit, it is that copy which ends up in the commit.
+
+**Important**: if you make changes to the file after adding it to the index, those changes will
+not end up in your commit, unless you add the file again to the index!
+
+ `git diff`
+ # shows the diff of your working copy
+
+ `git diff --cached`
+ # show the diff of your index
+
+Let's make some more changes and add some of these changes to the index.
# Undoing changes
Please sign in to comment.
Something went wrong with that request. Please try again.