Monday, January 30, 2017

How to Add Rails 5 project to git Repository

Goals

  • Create a local git repository
  • 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". In our case we're going to use git because it is (relatively) easy and it is what our app server, Heroku, uses.

Steps

Step 1

Type this in the terminal:
git init
It doesn't look like anything really happened, but git init initialized a new repository in a hidden directory called .git.
You can see this by typing ls -a (lisall files).

Step 2

Type this in the terminal:
git status
git status tells you everything git sees as modified, new, or missing.
You should see a ton of stuff under Untracked files.

Step 3

Type this in the terminal:
git add .
git add . 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 4

Type this in the terminal:
git status
Now you should see a bunch of files listed under Changes to be committed.

Step 5

Type this in the terminal:
git commit -m "Added all the things"
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.
-m "Added all the things" is just a shortcut to say what your commit message is. You can skip that part and git will bring up an editor to fill out a more detailed message.

Step 6

Type this in the terminal:
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!

More at http://docs.railsbridge.org/intro-to-rails/add_the_project_to_a_git_repo 

No comments:

Welcome to Rails.. Rails... Rails !

In 1995, I started the popular Clipper...Clipper... Clipper website (no blogs then) which was very popular and linked by virtually every Clipper-related site. When I switched to Windows via Delphi in 1997, I started the Delphi... Delphi... Delphi site. In June 2007, I discovered Ruby on Rails and no prize for guessing what I am gonna name this blog. which I started on 2nd October 2007.

As at 10th June 2010, we have 13,364 unique visitors from more than 84 countries such as Angola, Andorra, Argentina, Australia, Austria, Algeria,Barbados, Bosnia and Herzogovina, Belgium, Brazil, Bulgaria, Bangladesh, Belarus, Bolivia, Chile, Cambodia, Cape Vede, Canada, China, Colombia, Costa Rica, Croatia, Cyprus, Czech Republic, Denmark, Egypt, Estonia, Finland, France, Guadeloupe, Guatemala, Germany, Greece, Hong Kong, Hungary, India, Indonesia, Ireland, Israel, Italy, Japan, Kenya, Korea, Lithuania, Latvia, Malaysia, Mexico, Macao, Netherlands, Nepal, Norway, New Zealand, Oman, Panama, Peru, Poland, Portugal,Paraguay , Philippines, Romania, Russian Federation, Saudi Arabia, Singapore, Spain, Slovakia, Slovenia, Serbia, South Korea, Slovenia, South Africa, Spain, Switzerland, Sri Lanka, Sweden, Taiwan, Thailand, Turkey, United Arab Emirates, Ukraine, USA, UK, Venezuela, Vietnam

CCH
10th June 2010, 19:42