views:

172

answers:

8

I'm a Ruby on Rails developer and want to use Git for my next project, but I'm not pretty sure how to begin learning this.

I have too much basic questions like "Can I run my app from the repository?", or "Can I make a rollback in the live site?"

Any help will be apreciated.

+1  A: 

"Can I run my app from the repository?"

No, your repository just holds your files and their versions. You'll have to get a fresh download of the newest version of the files in your repository and copy them to your web server to update your app.

"Can I make a rollback in the live site?"

No, you'll have to roll back in github and replace the files on your site, just like if you made updates.

Github already has some good tutorials under the help section to get you started off right.

Robert Greiner
Both of your No answers are specific to GitHub hosted repositories, but Yes for many other options (for example).
Andrew Theken
@Andrew, good because OP asked for github specifically. Thanks for confirming.
Robert Greiner
Assuming OP has a mental distinction between "git" and "version control".. just saying, the question could be loosely-worded. Might help if @Andrew mentioned some examples.
Jeriko
Actually, it was my mistake. I used to think about git and github like the same thing. Sorry, Robert.
Erik Escobedo
+1  A: 

Depending on your use case, you can run everything from your git repo. Essentially, you've got your project structure, and at the root directory there is a hidden ".git" directory that contains all of the history and other info related to your repo. I know the owners of the site TekPub.com, so I am biased, but they have an excellent series on getting started with Git.

I would also look at "http://git-scm.com/documentation" for some good resources.

Andrew Theken
I would also consider "Heroku.com" for awesome Git/Ruby love.
Andrew Theken
+1  A: 

You can't run your app from the repository, but you can have hosted domains to repositories with pretty much static html files. I know of various blogs that are hosted off github. might wanna check out - http://pages.github.com/

Tarellel
A: 

Some additional reading apart from the advices above, Rails Tutorial Book - There's an introduction on working with Git & RoR. It'll give you the basic idea.

You can read it online http://www.railstutorial.org/book

Ed
+1  A: 

StackOverFlow has a great Post for you

Git for beginners: The definitive practical guide

Ahmed Kotb
+1  A: 

Since your question at its core involves how to deploy a Rails app in a version controlled environment, I'm surprised no-one has mentioned Capistrano or Vlad the Deployer. These popular tools for deployment can serve as a model for how your repository relates to your live app.

Here is the way Capistrano does it. When you tell it to deploy, it creates a new, timestamped directory on your server with the latest version from your repository in it. This timestamped directory is symlinked to the actual directory that your webserver looks at to find your app. Once Capistrano has finished retrieving all the files from git, it switches the symlink to point to the new directory. If you issue the rollback command, it just changes the symlink to point to the next older, timestamped directory (you usually keep a couple of older ones lying around).

The greatest benefit of this model is that changing the symlink instantly upgrades/downgrades every file in your app, so there are no issues of lag or missing dependencies.

You could of course implement this model (or similar) yourself, or you could just use either of these tools to do it for you.

Alison R.
A: 

The best way to learn Git for free is to look at the gitcasts.com. Scott Chacon is very good at explaining the concepts. For a great intro, take a look at http://www.gitcasts.com/posts/railsconf-git-talk

I would also recommend reading the online book progit.org/book.

Another helpful thing is to set up a search column in tweetdeck for #git. There are always helpful posts there.

Lastly, there are #git channels on IRC.

adymitruk
A: 

You don't necessarily have to do it all in one plunge.

Git can happily serve a frontend to a multitude of other VCS's, such as SVN and perforce. So, an easy way for you could be:

  1. Keep whatever VCS you're using now, but use Git to work with it.
  2. When you're past the Git learning curve, switch your master repository to Git. Alternatively, you might decide to keep things as is, because Git as a frontend will let you get many of Git's benefits while keeping your production workflow.
Alex Gontmakher