Other Pages

Add The Project To A Git Repo

Goals

  • Add all our files to the git repository

  • In order to publish our application, we need to add our application and any changes we make over time to a "revision control system". Rails already set up git for us.

Steps

Step 1

Find the Tool git, and press the Button 'Initialize Git Repository'

Step 2

Type this in the shell:
git status

git status tells you everything git sees as modified, new, or missing.

Right now there is nothing new to report.

Step 3

Type this in the shell:
git log

git log shows you everything that happend until now.

You will see one entry in the log, the 'Initial commit'.

git log showing inital commit

Step 4

Type this in the shell:
git add -A

git add -A tells git that you want to add the current directory (aka .) and everything under it to the repo.

git add

With Git, there are usually many ways to do very similar things.

  • git add foo.txt adds a file named foo.txt
  • git add . adds all new files and changed files, but keeps files that you've deleted
  • git add -A adds everything, including deletions

"Adding deletions" may sound weird, but if you think of a version control system as keeping track of changes, it might make more sense. Most people use git add . but git add -A can be safer. No matter what, git status is your friend.

Step 5

Type this in the shell:
git status

Now you should see a bunch of files listed in green under Changes to be committed.

Step 6

Type this in the shell:
git commit -m "empty Rail 7 app"

git commit tells git to actually do all things you've said you wanted to do.

This is done in two steps so you can group multiple changes together.

the Text after -m is a message to your future self or to other developers. Just a short description of what happened in this step.

Step 7

Type this in the shell:
git status

Now you should see something like nothing to commit, working directory clean which means you've committed all of your changes.

Explanation

By checking your application into git now, you're creating a record of your starting point. Whenever you make a change during today's workshop, we'll add it to git before moving on. This way, if anything ever breaks, or you make a change you don't like, you can use git as an all-powerful "undo" technique. But that only works when you remember to commit early and often!

Next Step: