lab 3 Create a Project
Goals
- Learn how to create a git repository from scratch.
Create a “Hello, World” program 01
NOTE: In this step, instead of creating a new 'hello' directory, just locate the cloned repository directory and change dir to it (later in the tutorial every mention of the 'hello' directory is actually this working directory).
Starting in your shell working directory, create an empty directory named “hello”, then create a file named hello.rb
with the contents below.
Execute:
mkdir hellocd <your-repository-url>
File: hello.rb
NOTE: when you see a "File:" instruction, you should create a new file with this name (e.g. by running: touch hello.rb) and add the following ruby code into it:
puts "Hello, World"
Create the Repository 02
NOTE: This step should be skipped, since we are already in a repository.
You now have a directory with a single file. To create a git repository from that directory, run the git init command.
Execute:
git init
Output:
$ git init Initialized empty Git repository in /Users/jim/working/git/git_immersion/auto/hello/.git/
Add the program to the repository 03
Now let’s add the “Hello, World” program to the repository.
Execute:
git add hello.rb git commit -m "First Commit"
You should see …
Output:
$ git add hello.rb $ git commit -m "First Commit" [master (root-commit) 9416416] First Commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 hello.rb