Can I import my heroku git repo into bitbuket? and how? - ruby-on-rails-3

My laptop died and I need to code from another computer.
I am working with Heroku and I want to get the latest version of code from Heroku to another machine.
I understood that it is very recommended to get a proper remote repository using GitHub or BitBucket.
I decided to try BitBucket.
While creating my account, it asks for the old URL of my git repo. Since my machine is dead, I was hoping to fill in the heroku URL but that didn't work.
Any ideas how to proceed?
The idea is that I could pull and push my changes from either machines (when my laptop comes from repair).

You can simply clone your Heroku repository to your local machine. Then add BitBucket as a remote and push the code there.
Find out the Heroku repo url on the settings page of your app
https://dashboard.heroku.com/apps/[APP]/settings
git clone git#heroku.com:[APP].git
git remote add bitbucket ssh://git#bitbucket.org/[ACCOUNT]/[REPO].git
git push bitbucket master

Related

Heroku repo has disappeared when pushing my rails app

I have been using heroku already for my rails app. I have come back to do some more work on the app but when I do
git push heroku master
I get
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
but
git remote -v
gives
origin git#github.com:x/guidelines.git (fetch)
origin git#github.com:x/guidelines.git (push)
So I assume that means that the repo is there somewhere? Any ideas where I'm going wrong?
Yes, don't worry all is fine.
You need to go to heroku.com and get the git URL of your application from the Apps > App Name > Settings page. You're looking for git#heroku.com:<application-name>.git.
Back at your command line readd the heroku remote via;
git remote add heroku git#heroku.com:<application-name>.git
and you'll be then able to push to the heroku remote.

Rails and Git push, Git pull: logs return same commit, changes aren't made

I've got a local branch (master), a GitHub repo (origin), and another remote repo (server). I've set up my remote so locally I can type git push server master and push the changes to server/master.
When I type git log -1 locally and on the server they return the same commit, but none of the changes I made locally are visible on the server.
I deployed my app with Capistrano so redeploying it makes the changes visible immediately, but I don't want to have to redeploy every time I make a change.
Any idea what's going on here? I'm rather new to Git. Hopefully it's something easy to fix.
It sounds to me that you maybe looking at a different directory than your web server is pointed to.
When I setup capistrano:
cap deploy:setup
#then
cap deploy
it creates a directory structure similar to:
/releases (each deploy gets its own randome number directory)
/current (a sym-link to the latest release)
/shared
None of these folder are tied to git. Which makes me think your webserver may not be pointed to the same directory that you're using with git.
--
You may find cap deploy is preferable as you'll be able to see the output if there are any issues.
I'm not a huge expert but the above is how I've setup rails with Capistrano.
Normally origin is the name used for the GitHub remote and not master. You can check what remotes you have by doing git remote show. If you want even more detail on the remote use git remote show origin (or whatever your remote is called, if it is not origin). This will give you a list. I suspect that what you have is actually two local branches (master and server). Try doing a git push server origin. This will take your server branch and put it on GitHub.
Alternatively
If you are trying to combine the changes in your server branch with your master branch then use checkout master and then git merge server. This will merge your changes from the server branch into your master branch and you can then upload to GitHub via git push master origin.

deploying to a test server before production on heroku

As I am new at this, I am not sure if this is how it should be -
I am making a webapp and using heroku for hosting
I want to have several developers working on the same code on github.
I'd like to have 2 servers on heroku - one for production and one for testing(is it also called staging?)
problem is I know what by doing git push heroku master from the webapp folder it will send it to the application to the heroku server which was setup in the first place.
How do I deploy to 2 different heroku instances from the same folder using git? Is it possible/ recommended?
When I push to github it's usually the master, should I have another branch for test?
Is there a way to transfer an app between heroku instances?
if there's a place where there is a recommended deployment routine for heroku and github I'd be happy to read it
When you run git push heroku master 'heroku' identifies the remote repository you are pushing to. In your case 'heroku' seems to be a reference to your production server. Similarly you probably have an 'origin' remote pointing to github.
If you list your git remotes you'll probably see something like this:
> git remote -v
heroku git#heroku.com:heroku_app_name.git (fetch)
heroku git#heroku.com:heroku_app_name.git (push)
origin git#github.com:your_github_org/repo_name.git (fetch)
origin git#github.com:your_github_org/repo_name.git (push)
To push to a different heroku app you can just add that app as a new git remote.
git remote add heroku-staging git#heroku.com:heroku_staging_app.git
Now you should be able to push to either remote as needed.
git push origin master //push to github
git push heroku-staging //deploy to staging
git push heroku master //deploy to production
In general I suggest that you should not be pushing to heroku manually. Hopefully you can have a continuous integration server watch github, run tests whenever you push changes, and deploy to staging only when your automated tests pass. You can then have a manually triggered CI task which pushes whichever commit is currently on staging to production as well (or even automate production deploys as well).
You can perform the same configuration using the heroku command line. That also gives you a good way to manage environment variables and other settings on both of your heroku apps:
https://devcenter.heroku.com/articles/multiple-environments

Authentication failed publishing a repository from Github for Windows

I am trying out Github for Windows and I am getting the following error when I try to publish a newly created repository.
Authentication failed
Your credentials may be out of date. Please log out of the application and then log back in before retrying the operation.
Needless to say I've logged out and back in multiple times without success. I've also uninstalled and installed the latest version to no avail.
The repository is a new one I created within the application and contains only the .gitattributes, .git and README files.
I am a complete newbie to Github so it's quite possible I've messed something up during the setup process.
I was able to solve this by:
Press Settings - Open in GitShell.
git status
git push (or pull)
introduce credentials (here is the most important step, somehow git client messed up or forgot your credentials).
After giving correct credentials you can exit from git shell and use git client again.
It turns out that the problem was Github for Windows was having a problem with the password it had stored. Github support's instructions were as follows:
Log out of Github for Windows.
Change my password on github.com
Log back into Github for Windows.
I was then able to publish my changes.
Did you setup your ssh keys?
https://help.github.com/articles/generating-ssh-keys#platform-windows

Heroku -- push not working

So I used heroku create with one of my apps, but then when on heroku.com I deleted the corresponding repository. I tried using heroku create again and it did give me another URL, but now when I try to push my app it keeps looking for the old one:
! No such app as [old name]
fatal: The remote end hung up unexpectedly
How do I get heroku to stop looking for this old app and use the newly created one?
Your local git repository has the old URL saved in its heroku remote. You have to update it using
git remote set-url --push heroku git#heroku.com:new_app.git
See Heroku's documentation and the Git manpage for more information.