<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.srevilak.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Intro_to_Git_I</id>
	<title>Intro to Git I - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.srevilak.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Intro_to_Git_I"/>
	<link rel="alternate" type="text/html" href="https://www.srevilak.net/wiki/index.php?title=Intro_to_Git_I&amp;action=history"/>
	<updated>2026-05-22T07:14:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://www.srevilak.net/wiki/index.php?title=Intro_to_Git_I&amp;diff=145&amp;oldid=prev</id>
		<title>SteveR: /* Looking at a git repository */ added gitk screen capture</title>
		<link rel="alternate" type="text/html" href="https://www.srevilak.net/wiki/index.php?title=Intro_to_Git_I&amp;diff=145&amp;oldid=prev"/>
		<updated>2014-11-06T02:48:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Looking at a git repository: &lt;/span&gt; added gitk screen capture&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:48, 5 November 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l65&quot;&gt;Line 65:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 65:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;like this:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;like this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;IMAGE&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  [[File:Gitk.png]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;I&amp;#039;ve used red lettering to describe what the different panels mean.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;I&amp;#039;ve used red lettering to describe what the different panels mean.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>SteveR</name></author>
	</entry>
	<entry>
		<id>https://www.srevilak.net/wiki/index.php?title=Intro_to_Git_I&amp;diff=143&amp;oldid=prev</id>
		<title>SteveR: initial revision</title>
		<link rel="alternate" type="text/html" href="https://www.srevilak.net/wiki/index.php?title=Intro_to_Git_I&amp;diff=143&amp;oldid=prev"/>
		<updated>2014-11-06T02:46:20Z</updated>

		<summary type="html">&lt;p&gt;initial revision&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;(11/4/2014)&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Tonight, we looked at [http://git-scm.com git], a tool for managing&lt;br /&gt;
revisions of files.&lt;br /&gt;
&lt;br /&gt;
You can put a single file under git version control, but git is&lt;br /&gt;
equally happy to work with a collection of files in a single directory&lt;br /&gt;
tree.  Git allows you to take snapshots (&amp;quot;commits&amp;quot;) of the directory&lt;br /&gt;
tree, and associate comments with individual snapshots.&lt;br /&gt;
&lt;br /&gt;
Given a collection of snapshots, git allows you to look back at&lt;br /&gt;
history.  For example, you can ask git to restore a specific snapshot,&lt;br /&gt;
or to show changes between two snapshots.&lt;br /&gt;
&lt;br /&gt;
You can also use git to synchronize files between two different&lt;br /&gt;
computers; we&amp;#039;ll explore this in the next class.  Tonight, we&amp;#039;re going&lt;br /&gt;
to focus on the git basics: editing files, and committing your&lt;br /&gt;
changes.&lt;br /&gt;
&lt;br /&gt;
== Installing Git ==&lt;br /&gt;
&lt;br /&gt;
For tonight&amp;#039;s class, we&amp;#039;ll want to install git and gitk.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;$ sudo apt-get install git gitk&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
apt-get is debian&amp;#039;s package manager.  If you&amp;#039;re using a different&lt;br /&gt;
package manager (yum, zypper, etc), just change the command line&lt;br /&gt;
accordingly.&lt;br /&gt;
&lt;br /&gt;
== Looking at a git repository ==&lt;br /&gt;
&lt;br /&gt;
For our first exercise, let&amp;#039;s download (&amp;quot;clone&amp;quot;) a public git&lt;br /&gt;
repository, and see what&amp;#039;s inside.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git clone &amp;lt;nowiki&amp;gt;git://git.mayfirst.org/mfpl/puppet&amp;lt;/nowiki&amp;gt;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  Initialized empty Git repository in /home/srevilak/puppet/.git/&lt;br /&gt;
  remote: Counting objects: 24884, done.&lt;br /&gt;
  remote: Compressing objects: 100% (10000/10000), done.&lt;br /&gt;
  remote: Total 24884 (delta 15688), reused 21853 (delta 13318)&lt;br /&gt;
  Receiving objects: 100% (24884/24884), 3.05 MiB | 1.89 MiB/s, done.&lt;br /&gt;
  Resolving deltas: 100% (15688/15688), done.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ cd puppet&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ ls -la&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  4 drwxr-xr-x  6 srevilak staff  4096 Nov  5 12:42 ./&lt;br /&gt;
 12 drwxr-xr-x 62 srevilak staff 12288 Nov  5 12:42 ../&lt;br /&gt;
  4 drwxr-xr-x  8 srevilak staff  4096 Nov  5 12:42 .git/&lt;br /&gt;
  4 -rw-r--r--  1 srevilak staff    25 Nov  5 12:42 .gitignore&lt;br /&gt;
  4 drwxr-xr-x  2 srevilak staff  4096 Nov  5 12:42 helper/&lt;br /&gt;
  4 drwxr-xr-x  3 srevilak staff  4096 Nov  5 12:42 manifests/&lt;br /&gt;
  4 drwxr-xr-x  3 srevilak staff  4096 Nov  5 12:42 modules/&lt;br /&gt;
&lt;br /&gt;
The repository we&amp;#039;ve just cloned contains three directories (helper,&lt;br /&gt;
manifests, and modules), and one file (.gitignore).  The &amp;quot;.git&amp;quot;&lt;br /&gt;
directory is where git keeps its versioning information.&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s browse a little history, using gitk.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ gitk&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
gitk is a graphical program.  When it starts, you should see something&lt;br /&gt;
like this:&lt;br /&gt;
&lt;br /&gt;
IMAGE&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ve used red lettering to describe what the different panels mean.&lt;br /&gt;
Essentially, you&amp;#039;re looking a change history: you can see who made&lt;br /&gt;
each change, when, and the actual differences.  Try clicking around in&lt;br /&gt;
the top three panels to see what the different changes are.&lt;br /&gt;
&lt;br /&gt;
== Making and using your own git repository ==&lt;br /&gt;
&lt;br /&gt;
Suppose we&amp;#039;re writing a newsletter, and want to use git to keep track&lt;br /&gt;
of changes.  Let&amp;#039;s make a new directory for our newsletter work, and&lt;br /&gt;
create a git repository in that directory.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ cd nl&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git init&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  Initialized empty Git repository in /home/srevilak/nl/.git/&lt;br /&gt;
&lt;br /&gt;
That&amp;#039;s all there is to creating a repository.  Let&amp;#039;s ask git for some&lt;br /&gt;
information about the repository we just created&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git status&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  # On branch master&lt;br /&gt;
  #&lt;br /&gt;
  # Initial commit&lt;br /&gt;
  #&lt;br /&gt;
  nothing to commit (create/copy files and use &amp;quot;git add&amp;quot; to track)&lt;br /&gt;
&lt;br /&gt;
Nothing interesting yet -- git is just saying &amp;quot;you haven&amp;#039;t asked me to&lt;br /&gt;
track any files&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s create a file, and commit it.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ touch hello.txt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git add hello.txt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git commit&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The first line (touch hello.txt) creates an empty file called &amp;quot;hello.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The second line (git add) tells git that you&amp;#039;d like to include&lt;br /&gt;
hello.txt in the next snapshot.&lt;br /&gt;
&lt;br /&gt;
The third line (git commit) creates the new snapshot.  After typing&lt;br /&gt;
&amp;quot;git commit&amp;quot;, git should open an editor, and ask you to provide a&lt;br /&gt;
commit message -- a comment about the snapshot you&amp;#039;re about to create.&lt;br /&gt;
You can give a comment like &amp;quot;added hello.txt&amp;quot;, save, then exit the&lt;br /&gt;
editor.&lt;br /&gt;
&lt;br /&gt;
At this point, we can go back and review history&lt;br /&gt;
  &lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git log&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  commit 08d55e16aaf97f91c71822b42aa5845e1614e5ff&lt;br /&gt;
  Author: Steve Revilak &amp;lt;steve@srevilak.net&amp;gt;&lt;br /&gt;
  Date:   Wed Nov 5 12:49:49 2014 -0500&lt;br /&gt;
  &lt;br /&gt;
      added hello.txt&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git log&amp;quot; shows information about commits made to the repository; like&lt;br /&gt;
a non-graphical gitk.  Here, you see that I&amp;#039;ve made one commit, with&lt;br /&gt;
the comment &amp;quot;added hello.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now, let&amp;#039;s change hello.txt, and run git status.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ echo &amp;quot;hello&amp;quot; &amp;gt;&amp;gt; hello.txt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git status&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  # On branch master&lt;br /&gt;
  # Changed but not updated:&lt;br /&gt;
  #   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
  #   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
  #&lt;br /&gt;
  #       modified:   hello.txt&lt;br /&gt;
  #&lt;br /&gt;
  no changes added to commit (use &amp;quot;git add&amp;quot; and/or &amp;quot;git commit -a&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Note the output from &amp;quot;git status&amp;quot;.  Git is saying &amp;quot;you&amp;#039;ve modified&lt;br /&gt;
hello.txt -- use &amp;#039;git add&amp;#039; to incorporate this file into the next&lt;br /&gt;
snapshot, or &amp;#039;git checkout&amp;#039; to undo the modifications.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
With text-based files, git can show you exactly what changed:&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git diff&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  diff --git a/hello.txt b/hello.txt&lt;br /&gt;
  index e69de29..ce01362 100644&lt;br /&gt;
  --- a/hello.txt&lt;br /&gt;
  +++ b/hello.txt&lt;br /&gt;
  @@ -0,0 +1 @@&lt;br /&gt;
  +hello&lt;br /&gt;
&lt;br /&gt;
&amp;quot;diff&amp;quot; shows differences between files (like what we saw in gitk&amp;#039;s&lt;br /&gt;
lower left panel).  In this case, git is showing us the difference&lt;br /&gt;
between the last snapshot, and the current state of the files.&lt;br /&gt;
&amp;quot;+hello&amp;quot; means that the line &amp;quot;hello&amp;quot; was added to hello.txt.&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s add hello.txt to the snapshot, and commit the changes.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$git add hello.txt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git commit -m &amp;quot;very rough draft of the hello file&amp;quot;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  [master a0bc7c0] very rough draft of the hello file&lt;br /&gt;
   1 files changed, 1 insertions(+), 0 deletions(-)&lt;br /&gt;
&lt;br /&gt;
Above, I used the &amp;quot;-m&amp;quot; option to specify a commit message on the&lt;br /&gt;
command line.  Try running &amp;quot;git log&amp;quot; and verify that you see a second&lt;br /&gt;
commit with this message.&lt;br /&gt;
&lt;br /&gt;
Here&amp;#039;s an example that uses git to undo a change.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ echo &amp;quot;A questionable change to hello.txt&amp;quot; &amp;gt;&amp;gt; hello.txt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git diff&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  diff --git a/hello.txt b/hello.txt&lt;br /&gt;
  index ce01362..1b2eab7 100644&lt;br /&gt;
  --- a/hello.txt&lt;br /&gt;
  +++ b/hello.txt&lt;br /&gt;
  @@ -1 +1,2 @@&lt;br /&gt;
   hello&lt;br /&gt;
  +A questionable change to hello.txt&lt;br /&gt;
&lt;br /&gt;
The first command added &amp;quot;A questionable change to hello.txt&amp;quot; to the&lt;br /&gt;
file hello.txt.  The second command uses &amp;quot;git diff&amp;quot; to see the change.&lt;br /&gt;
Now, suppose I don&amp;#039;t like the questionable change, and want to git rid&lt;br /&gt;
of it.&lt;br /&gt;
&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git checkout -- hello.txt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;$ git status&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  # On branch master&lt;br /&gt;
  nothing to commit (working directory clean)&lt;br /&gt;
&lt;br /&gt;
The first line (git checkout) tells git &amp;quot;replace hello.txt with the&lt;br /&gt;
copy from the last commit&amp;quot;.  The second line uses &amp;quot;git status&amp;quot; to check&lt;br /&gt;
for changed files; the response &amp;quot;working directory clean&amp;quot; tells us&lt;br /&gt;
that there are no uncommitted changes.  In other words, we&amp;#039;ve backed&lt;br /&gt;
out our questionable change.&lt;br /&gt;
&lt;br /&gt;
Now, take a look at hello.txt, and verify that &amp;quot;A questionable change&lt;br /&gt;
...&amp;quot; is no longer there.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux Class]]&lt;/div&gt;</summary>
		<author><name>SteveR</name></author>
	</entry>
</feed>