How to Update Your Fork on Github for Windows

I have installed GitHub for Windows and don’t regret it. It saved me remembering every git command, and let me work more easily with repositories.

I am sure,  not many developers will download it, specially Ruby on Rails developers who are used to writing commands and are not fan of development using tools with rich UI.

But for me, I needed something to simplify my git workflow, while working with others on an open source project related to Ruby on Rails facebook group.

One of the main processes developers use on open source projects are forking and updating their forks with the original repository.

Unfortunately this feature is still not available on GitHub for Windows 1.2.3.0 (Nov 13).

I checked with the wonderful support team of GitHub

My question:

Is it true that, in GitHub for Windows, we cannot update our fork with the last commits from the original repository, and we have to do it using the shell manually?

Their answer:

That’s correct. We know how important this is in the ‘fork and submit pull request’ workflow, and as a result this is high on our list of things to implement in GitHub for Windows. Unfortunately I can’t give a firm date for when we’ll release this feature.
 
Thanks for letting us know you’d like to see this added, and be sure to keep an eye on github.com/blog and the GitHub for Windows release notes for updates.

So for now if you need to update your fork with the latest from the original repository, you will have to run the shell as shown below:

then run the commands:

git remote add upstream https://github.com/user/original_repo_you_forked_from

git fetch upstream
git merge upstream/master

Then press the sync button, to sync to your fork on github website.

 

 

Deploying Ruby on Rails Applications for Beginners

You always see on Rails forums, rails newbies asking about their best option for hosting their small web app.

In the world of php, deploying is a much simpler process with choices among thousands of good cheap hosts.

When it comes to Rails less options are available, although significantly increasing these days, and process is more complicated.

The biggest issue arises when you are like me a Windows user and developed your app on your Windows machine. Of course, the first thing every other developer may tell you is to move to Linux (Ubuntu is by far the most popular).

Actually moving to Linux for Rails developers may be the right decision which I still have not taken. And this is why I made this blog.

( As you may have already noticed I usually target new rails developers on Windows )

So the most recommended host for beginners, is Heroku, extremely to use and usually it is easy to move your site from your local Windows machine to their servers. The problem with Heroku is their prices. They have a free basic account, but does not offer much, if you get some traffic, soon you will have to upgrade and rate will jump drastically.

After some research I found that my best bet is to use Digital Ocean

Their basic account is for $5 a month, no other Rails host can beat that, trust me.

Now after registering with Digital Ocean, I found it a bit complicated to move my local Rails App to their cloud, so I was introduced to Cloud 66

They say it very clearly: Cloud 66 makes deploying and running of Ruby on Rails apps simple. And it is so true. All you need is your Digital Ocean account, and your app on github. Cloud66 will analyze your code and create the right environment on Digital Ocean.

Have Ruby on Rails Installed on Windows the Best Way

This is a complete step by step instructions with minimal explanations, on how to set up your Windows machine for starting building your RoR application in the most efficient and professional way.

Most of this is inspired from the Michael Hurtl most recommended Rails book 

1. Download and install RailsInsaller

2. Download and install Console 2

3. Download and install Sublime Text 2

4. Download and install Herkou Toolbelt

5. Open Console 2

6. Navigate through cd commands to a folder where you want your app folder to be created

7. Run rails new applicationname (will create the application directory with all rails default sub-directories and files)

8. Open gemfile with Sublime Text 2 and change as per your required gems. I found the gemfile used by Rails tutorial book is perfect to use in every application, then add gems when you need later. But make sure you:
  – remove rb-fsevent, growl, rb-inotify, libontify
  – add 

gem ‘rb-fchange’, ‘0.0.5’
gem ‘rb-notifu’, ‘0.0.4’
gem ‘win32console’, ‘1.3.0’

Google the pages of these gems to check their latest version and change the version number accordingly

9. Navigate with Console 2 to your newly created app folder and run bundle install

10. Run rails s

Congratulations you now have rails server running with some beautiful essential gems.

11. git init

12. git add .

13. git commit -m “Initial commit”

14. Create git account on github

15. git remote add origin https://github.com/%5Busernane%5D/%5Brepositaryname%5D.git

16. git push -u origin master

Congratulations you have just set up Git to work smoothly with your app.

17. Create a heroku account

18. Run heroku login on console 2

19. heroku create

20. git push heroku master

Congratulations you have hosted your app on Heroku.

The most recommended testing environment is rspec, and here is the best way to install it with the best supporting gems and options.

21. In console 2, run rails generate rspec:install

22. bundle exec guard init rspec (guard gem for autotesting)

23. change content of guardfile to the one used in the tutorial

24. bundle exec spork –bootstrap (spork gem for speeding up tests)

25. Change content of spec/spec_helper.rb to the one used in the tutorial

26. Change content of .rspec file to 

--colour
--drb

27. bundle exec guard init spork (to tell rails to use spork with guard)

28. add :cli => ‘–drb’ argument to guard ‘rspec’ line in guardfile

29. In sublime text 2 go to preference -> Package Control and select install package find  rubytest and have it installed.

30. preference -> Package Settings->RubyTest->Settings – User add bundle exec before any rspec you find

Congratulations you now have rspec testing framewrok installed with the best supporting gems to autotest, notify, and speed things up. You can also now run tests from Sublime Text 2 itself.

In thirty steps you now have everything ready for the best development environment on Windows for any serious application development.Image

Git

We need to use Git to upload our code and keep versions of it and calibrating with others in writing code.

Most serious Ruby on Rails developers keep a copy of their code at Git Hub. The free access keeps code public, a model to encourage open source software development, If you need your app to be private you can open a paid private account.
You will have to copy and paste the key of your rails project to your account.
Actually, when you install a Rubyonrails installer for windows, you will get the key. If you don’t have it, please follow these instructions

As per the tutorials am currently doing (am watching the videos not the book…you can buy them from the same site. Trust me they are worth the price. (an am not affiliated in anyway)). and forgive the ugly website layout and the “spammy” feel. It is not.

– There is a .gitignore file in your app folder, where it indicates which files needs to be ignored by git. (think of it like a backup system which need to know which files need not to be included in the sync operation)
Change your .gitignore file content to this. It is the recommended and used one by Michael Hartl.

You can also use this one, frequently updated made by the rails community on github

 

# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile ~/.gitignore_global

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3# Ignore all logfiles and tempfiles.
/log/*.log
/tmp# Ignore other unneeded files.
doc/
*.swp
*~
.project
.DS_Store
.idea

The tutorial teaches basic commands from the git command line.

These are the basics:

$ git add .  (this will add all files listed in the directory we are running the command from, to be included in the further pushing commit, push, pull requests)
$ git commit -m “Initial commit”
$ git status
$ git push -u origin master
$ git remote add origin git@github.com:railstutorial/first_app.git

I will not go through all details of git in this post.. but if you want to save your time of learning GIT command. You can cheat and use
the Github Windows Client. Am not installing it. At this stage I prefer to learn the commands. It will be easier later for me to understand the ins and outs of the clients

PS: If you feel too serious about learning Git system. Then this the most recommended book and its online for free.

Today's latte, brand-new Git logo!

Today’s latte, brand-new Git logo! (Photo credit: yukop)