Create a Project

Goals

  • Learn how to create a git repository from scratch.

Create a “Hello, World” program

Starting in the empty working directory, create an empty directory named “hello”, then create a file named hello.rb with the contents below.

Execute:

  1. mkdir hello
  2. cd hello

hello.rb

  1. puts "Hello, World"

Create the Repository

You now have a directory with a single file. To create a git repository from that directory, run the git init command.

Execute:

  1. git init

Output:

  1. $ git init
  2. Initialized empty Git repository in /Users/jim/Downloads/git_tutorial/work/hello/.git/

Add the program to the repository

Now let’s add the “Hello, World” program to the repository.

Execute:

  1. git add hello.rb
  2. git commit -m "First Commit"

You should see …

Output:

  1. $ git add hello.rb
  2. $ git commit -m "First Commit"
  3. [master (root-commit) 4445720] First Commit
  4. 1 file changed, 1 insertion(+)
  5. create mode 100644 hello.rb