开发者

How to begin working with git? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

开发者_开发知识库 Improve this question

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.


StackOverFlow has a great Post for you

Git for beginners: The definitive practical guide


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.


"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.


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/


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.


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


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.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜