Skip to content

Commit

Permalink
Added a bunch of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hindol committed Oct 5, 2012
1 parent afff9d0 commit fdebf28
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions GETTING-STARTED-WITH-GIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Let us create an _empty_ `git` repository. It is analogous to buying a bookshelf
> `Initialized empty Git repository in git-tutorial/examples/prime/.git/`
## Create Content
Let us say, you are asked to write a prime number generator in C++ by your teacher. So we are going to create a bare-bones C++ file called `prime.cpp`.
Let us say, you are asked to write a prime number checker in C++ by your teacher. So we are going to create a bare-bones C++ file called `prime.cpp`.

Create a file named `prime.cpp` inside your prime directory and paste the following,

Expand All @@ -22,7 +22,7 @@ Create a file named `prime.cpp` inside your prime directory and paste the follow
return 0;
}

You have read somewhere that the recommended way to work with `git` is ___commit early, commit often___. So you are thinking, "this might be a good time to take a snapshot of my file and put it in the repository". Let's do that.
You have read somewhere that the recommended way to work with `git` is ___commit early, commit often___. So you are thinking, "this might be a good time to take a snapshot of my file and put it in the repository." Let's do that.

$ git add prime.cpp
$ git commit -m 'First version'
Expand Down
28 changes: 28 additions & 0 deletions REVERT-CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Revert Changes
Hopefully you have not forgotten about your assignment from the last chapter. But who wants to do an assignment? (Not me at least.) Luckily, you have a friend who has already done it. Let's copy his assignment,

bool CopiedIsPrime(int n)
{
for (int i = 2; i < n; ++i)
{
if (n % i == 0)
return false;
}
return true;
}

Paste this function just before `int main()`. Commit your changes,

$ git commit prime.cpp -m 'Borrowed IsPrime() from a friend (don't tell the teacher)'

> Note that `git add` is not required here since we are explicitly mentioning the name of the file we want to commit.
That's it. An assignment well done!

Well, not quite...
Unfortunately for you, your teacher is also a frequent visitor of GitHub and he sees your commit message. Now he is really angry. He screams, "Either you do it yourself or I will fail you." So you type,

$ git reflog

> `4c29248 HEAD@{0}: commit: Borrowed IsPrime() from a friend (don't tell the teach
974dbe5 HEAD@{1}: commit (initial): First version`

0 comments on commit fdebf28

Please sign in to comment.