Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes - mostly formatting #1

Merged
merged 13 commits into from
Jul 17, 2011
43 changes: 23 additions & 20 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ branches config description HEAD hooks info objects refs

h2. Adding new files

Now, let's try adding some files into the project. Create a couple of files. For example, I
create two files named @bob.txt@ and @alice.txt@.
Now, let's try adding some files into the project. Create a couple of files. For example, I create two files named @bob.txt@ and @alice.txt@.

<pre>

In your working directory, create two files named alice.txt and bob.txt

</pre>

In Git, you add content to the @staging area@ first by using @git add@ and then
finalizing the process to record it into the git index by using @git commit@
Let's use a mail analogy.

Now to add the files to the staging area
In Git, you first add content to the @staging area@ by using @git add@. This is like putting the stuff you want to send into a cardboard box. You finalize the process and record it into the git index by using @git commit@. This is like sealing the box - it's now ready to send.

Let's add the files to the staging area

<pre><code>
$ git add alice.txt bob.txt
Expand Down Expand Up @@ -145,18 +145,20 @@ Now let's add our modified file to the staging area

<pre>

Add @alice.txt@ to the staging area. (Ask for help if you are stumped)
Add <b>alice.txt</b> to the staging area. (Ask for help if you are stumped)

</pre>

<pre>

Now, check the @status@ of @alice.txt@. Is it in the staging area now?
Now, check the <b>status</b> of <b>alice.txt</b>. Is it in the staging area now?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, any formatting in pre tags do not work. :) not a biggie


</pre>


Let's say we did not like putting Lorem ipsum into @alice.txt@. One advantage of a staging area is to enable us to back out before we commit - which is a bit harder to back out of. Here's how to back out of the staging area :
Let's say we did not like putting Lorem ipsum into @alice.txt@. One advantage of a staging area is to enable us to back out before we commit - which is a bit harder to back out of. Remembering the mail analogy - it's easier to take mail out of the cardboard box before you seal it than after.

Here's how to back out of the staging area :

<pre><code>
$ git reset HEAD alice.txt
Expand Down Expand Up @@ -188,7 +190,9 @@ You have now un-done your changes. Your file is now empty

h2. Branching

Creating a branch in Git is easy. The @git branch@ command, used by itself will list the branches you currently have
Most large code bases have at least two branches - a 'live' branch and a 'development' branch. The live branch is code which is OK to be deployed on to a website, or downloaded by customers. The development branch allows developers to work on features which might not be bug free. Only once everyone is happy with the development branch would it be merged with the live branch.

Creating a branch in Git is easy. The @git branch@ command, when used by itself, will list the branches you currently have

<pre><code>
$ git branch
Expand All @@ -198,7 +202,7 @@ $ git branch

The @*@ should indicate the current branch you are on, which is @master@.

If you wish to start another branch, use @git branch (new-branch)@ :
If you wish to start another branch, use @git branch (new-branch-name)@ :

<pre><code>
$ git branch exp1
Expand All @@ -215,7 +219,7 @@ $ git checkout exp1
Switched to branch 'exp1'
</code></pre>

@git checkout (branch)@ is used to switch branches.
@git checkout (branch-name)@ is used to switch branches.


Let's perform some commits now,
Expand Down Expand Up @@ -243,7 +247,7 @@ index 0000000..2ef267e
+some content
</pre></code>

Basically what the above output says is that test.txt is present on the @exp1@ branch, but is absent on the @master@ branch.
Basically what the above output says is that @test.txt@ is present on the @exp1@ branch, but is absent on the @master@ branch.


Git is good enough to handle your files when you switch between branches. Switch back to the @master@ branch
Expand All @@ -261,8 +265,7 @@ $ ls
README.textile alice.txt bob.txt gamow.txt
</code></pre>

As you can see the new file you created in the other branch has disappeared. Not to worry, they are safely tucked away,
and will re-appear when you switch back to that branch.
As you can see the new file you created in the other branch has disappeared. Not to worry, it is safely tucked away, and will re-appear when you switch back to that branch.

<pre>

Expand Down Expand Up @@ -298,8 +301,7 @@ You always specify the branch you want to merge from, and you have to be in the

At this point, you can also try out @gitk@ to visualize the changes and how the two branches have merged

Git is pretty good at merging automagically, even when the same file is edited. There are however,
some situations where the same line of code is edited there is no way a computer can figure out how to merge.
Git is pretty good at merging automagically, even when the same file is edited. There are however, some situations where the same line of code is edited there is no way a computer can figure out how to merge.
This will trigger a conflict which you will have to fix.

h2. Merge Conflicts
Expand All @@ -314,16 +316,16 @@ Branch alpher set up to track remote branch alpher from origin.
Switched to a new branch 'alpher'
</code></pre>

You should now have a new branch called alpher. Try merging that branch into master now and fix the ensuing conflict.
You should now have a new branch called @alpher@. Try merging that branch into @master@ now and fix the ensuing conflict.

<pre>

Merge the @alper@ branch into @master (as you did when you merged exp1 into master) (Ask for help if stumped)
Merge the alpher branch into master (as you did when you merged exp1 into master) (Ask for help if stumped)

</pre>


You should see a @conflict@ with the gamow.txt file. This means that the same line of text was edited and committed on both the master branch and the alpher branch. The output below basically tells you the current situation
You should see a @conflict@ with the @gamow.txt@ file. This means that the same line of text was edited and committed on both the master branch and the alpher branch. The output below basically tells you the current situation

<pre><code>

Expand Down Expand Up @@ -386,7 +388,7 @@ I throughly recommend these resources to continue your Git practice:

* <a href="http://progit.org">http://progit.org</a> (buy the book at http://tinyurl.com/amazonprogit)
* <a href="http://gitref.org">http://gitref.org</a>
* http://www.kernel.org/pub/software/scm/git/docs/everyday.html
* <a href="http://www.kernel.org/pub/software/scm/git/docs/everyday.html">http://www.kernel.org/pub/software/scm/git/docs/everyday.html</a>



Expand All @@ -395,3 +397,4 @@ h2. Author
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">http://creativecommons.org/licenses/by-nc-sa/3.0/</a>
Author: Thong Kuah
Contributors: Nick Malcolm