Rails: Rubymine: GitHub - ruby-on-rails

I can't seem to figure out how to commit my files to GitHub.
I am using RubyMine 4.5 on the MAC
I have git set up locally
I have a private account on GitHub
From the RubyMine Preferences, I have my GitHub credentials properly set up (and acknowledged as such by RubyMine), but it did not give me an option to select a repository on GitHub.
How do I commit file to the GitHub repository? There are too many CVS and Git menu items in RubyMine.
PS: I've read the online help sections (the only thing available to me), and I followed the instructions in the GitHub integration, but the directory I'm trying to commit is failing to push to GitHub, with RubyMine telling me that there was nothing to commit. This is the first time I use RubyMine for GitHub. Nothing about this on StackOverflow.

Okay, I think I've recreated your situation locally and it appears that RubyMine has terrible support for managing remotes. If you create a Git repository locally, then (separately) create a repository on GitHub, there's no obvious way to marry the two from within RubyMine.
Basically, you need to set up GitHub as a remote for your local repository from the shell, and once that's done then RubyMine will be able to push as normal.
Please note that the below instructions assume you want to overwrite your GitHub repository with the full history from your local repository -- If your GitHub repository has data that you do not want to lose, do not execute these commands! See Below.
Open up Terminal:
cd /path/to/my/project/root
git remote add origin https://github.com/yourusername/yourrepo.git
git push -u origin +master
Now, RubyMine should be able to push to your GitHub repository via VCS > Git > Push
If your GitHub repository has already been committed to and you don't want to lose those changes, you'll need to either create a new GitHub repo or clone your GitHub repo into another folder and merge your local repository into the clone.
This can be avoided entirely if you're trying to push your existing local repository to a new GitHub repo: Simply use the VCS > Import into Version Control > Share project on GitHub option and use the dialog to create a new GitHub repository.

Related

Git setup in RubyMine VCS for windows 7?

I am new in ruby on rails. i want to save my demo projects on github can any one help me to setup git in RubyMine IDE. Step by Step Help will be appreciated. I tried every link but didnt help out.
I tried following link.
http://www.jetbrains.com/ruby/webhelp/using-git-integration.html
I'll give it a shot and try to break down that tutorial into steps.
First, make sure you have git installed on your machine, if not there is a great tutorial to install git on windows by Github.
This is just one way to do it, but in a general overview
First create a local git repository with RubyMine
Next, add untracked files to the git repository with RubyMine
After then, commit changes to the git repository with RubyMine
Then, you create a repository on Github and push to your remote repository on Github with RubyMine
You can also do all of these things from the Git Bash command line or Github for Windows GUI as well.
Hopefully this helps.

Understanding GitHub work flow; what to do after cloning from github?

I am working with RoR, and have recently cloned a project via GitHub. I have a specific RVM gemset for this project, but nothing inside of it. I am not sure if I should create a new branch and then run bundle install, or vice versa. My concern is I do not want to work on the master branch, but I know I need to set up everything first run bundle install.
What is the right method to get started on this project, with out breaking the master?
GitHub is just a hosting for git repositories. Well, writing just is not giving it proper justice.
However you should learn how truly git works. I heartily recommend reading free Git Book.
In short:
git is distributed
you're working only on local working copy
if you don't tell git specifically you want a file to be tracked - it won't (surprise, surprise!).
So running bundle install will not modify what is tracked by git and - specifically - won't affect remote master. It won't modify your master until you modify some files being already tracked. I think bundle install does not. And even then to modify remote master you need to commit and push changes.
You can work on your master. It's safe.
If its someone else's project, or an open-source project, you should Fork the project on Github. Then clone the fork. This will allow you to work on the project, commit your changes locally and push them back to the forked repository.
If it is your own project, and you do indeed want to work in a branch, then clone the repo and make a branch git checkout -b my_branchname. You will then work in the branch, check your code into the branch. Eventually you will want to merge this branch into the master branch. To do this you can merge locally:
git checkout master
git merge my_branchname
Or, you can create a pull request on Github and then merge the branch into master through the Github web UI.
The bundle command, used in conjunction with RVM will just install gems locally, most likely in your home directory (~/.rvm). Gems are not packaged with the rest of the code, so you don't need to fear messing up the master repo.

Setting up Github on a new computer

I am an almost perfect beginner at Github so please humor me with this elementary question.
I have a laptop PC that I've been using to interact with a repo on Github. I just bought a Mac and I would like to do my programming on both machines.
I have installed Git on the new machine and I have set up my username, e-mail, and Github token on the Terminal.
What are the basic commands I need to do this:
Download the repo from Github the first time? I've created a new folder on my Mac but going there and typing git pull git#github.com/sscirrus/repo.git produces fatal: not a repository (or any of the parent directories): .git.
Upload those changes again such that the main repo is updating cleanly with each new push. I assume that once I have the code in my new folder, it would be a matter of git add . and git push with password entry?
I am reading through tutorials on Git but just want to make sure I'm doing something sensible for my situation before my newbieness screws up a lot of prior work. Thank you!
Go through this book, http://progit.org/book/ and http://gitcasts.com/ for video tutorial.
And I recommend you follow these steps
Clone the repository (git clone repoAddress)
create a new branch (git branch branchName)
checkout that branch (git checkout branchName)
make changes and commit in that branch (git add files)
checkout master (git checkout master)
perform a pull (it updates the local repository with the remote one) git pull
If there is change, checkout the branch and rebase it with local master
If there is conflict resolve it and add that file and make a commit again
checkout master again and merge the branch (git merge branch)
push the commits to the remote repository.(git push)
If you want a GUI tool, then there is GitX which is made for Mac OS X. http://gitx.frim.nl/
Download the git repo for first time - do a clone of the repo first. this will bring your code from github to your machine for the first time.
git clone your_git_repo_url
from second time, you can
git pull your_git_repo_url
Upload the changes after commits
git push your_git_repo_url
Please read scott chacons git books. these will get you the basics of git. and learning this will help in the long run.
You need to use git clone, not git pull.
You'll want to git commit after add and before push. add just adds something to the index (Worst name ever. The "index" is essentially a pending commit.) and commit actually commits it to your repository. push then pushes committed stuff from your local repository to a remote repository.
Whilst there's a lot to be said for using git from the command line (to help understanding) you might like to try the github clients (for mac & windows - download them from the github homepage - at the bottom in the section marked 'clients') which I'm guessing might not have been available when you posted your question.
The Windows one lets you specify a default storage directory (where it clones the repos into) - the Mac one prompts you with each clone as to where you want to stick it.
Both very easy to use to do what you want (clone, pull, push etc and also good for seeing what branches you have and changing between them)

Git + GitHub + Heroku

I am new to the world of Git, GitHub and Heroku. So far, I am enjoying this paradigm but coming from a background with SVN, things seems a bit complicated to me in the world of Git. I am facing a problem for which I am looking for a solution.
Scenario:
1. I have setup a new private project on GitHub. I forked the private project and now I have the following structure in my branch:
/project
/apps
/my-apps
/my-app-1
....
/my-app-2
....
/your-apps
/your-app-1
....
/your-app-2
....
/plugins
....
I can commit the code in my Fork on GitHub from my machine in any of the folders I want. Later on, these would be pulled into the master repository by the admin of the project.
2. For every individual application in the apps folder, I have setup an app on Heroku which is a Git Repo in itself where I push my changes when I am done with the user stories from my local machine. In short, every app in the apps folder is a Rails App hosted on Heroku.
Problem:
What I want is that when I push my changes into Heroku, they can be committed into my project fork on GitHub as well, so, it also has the latest code all the time.
The issue I see is that the code on Heroku is a Git Repo while the folders which I have on GitHub are part of a Repo.
So far, what I have researched is that there is something known as Submodule in the Git World which can come to the rescue, however, I have not been able to find some newbie instructions.
Can someone in the community be kind enough to share thoughts and help me to identify the solution of this problem?
The idea behind submodules is that they're all separate git repositories that you can include into a master one and rather instead of including all the files it includes a link to that submodule instead.
How to use submodules
To use a submodule, first you must extract out the directory and create it as its own git repository by using git init. Then you can upload this separately to Github or [place of your choosing] and to use it as a submodule use the command: git submodule add [place/to/put/it] git://github.com/you/proj1.
Separation is best
I would think it better to leave these separated out as their own git repositories and push to heroku from each one. The reason? It's more likely (I feel) that you're going to be working on one at a time and doing a git commit and git push heroku master for that one only.
If you wished however to deploy all applications at the same time you could recurse down the directory tree using this Ruby script placed in the top-level directory:
Dir["**/*"].select { |dir| File.directory?(dir) }.each do |f|
Dir.chdir(dir) do
`git push origin master`
`git push heroku master`
end
end
Of course this would only work if you have staged all your changes. I can't think of a way to automate that as Ruby <= 1.9 doesn't have the module to read your thoughts.

Whats the best way to work with Github and multiple computers?

I am developing some school grading software and decided to use Github to host the project. After building some code on my Ubuntu box I pushed it to Github and then cloned it down to my MacBook Pro. After editing the code on the MBP I pushed it back to Github. The next morning I tried to update my repo on the Ubuntu box with a git pull and it gave me all kinds of trouble.
Whats the best way to work in this situation? I don't want to fork my own repo and I don't really want to send myself emails or pull requests. Why can't I just treat Github like a master and push/pull from it onto all of my personal repos on different computers?
I'll assume your problem was that the machine on which you first created the repo crapped out when you tried to issue the git pull command.
When you clone an existing git repository (like you did on your 2nd machine, the MacBook Pro), you're automatically set up to so your git pull commands will automatically merge the remote with your local changes.
However, when you initially create a repo and then share it on a remote repository, you have to issue a few commands to make things as automated as a on cloned repo.
# GitHub gives you that instruction, you've already done that
# git remote add origin git#github.com:user_name/repo_name.git
# GitHub doesn't specify the following instructions
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
These last few instructions configure git so future git pull's from this repo will merge all remote changes automatically.
The following is a bit of shameless self-promotion. If you use Ruby, I have created a Ruby-based tool that lets you deal with all these kinds of things with git remote branches. The tool is called, unsurprisingly, git_remote_branch :-)
If you don't use Ruby, my tool is probably gonna be too much of a hassle to install. What you can do is look at an old post on my blog, where most of the stuff grb can do for you was explicitly shown. Whip out your git notes file :-)
You can also add multiple SSH public keys.

Resources