I have two computers and want to use only one for deployment.
I regularly do push to my private git repo on another computer and on the current computer I do both push to git repo and deploy to heroku.
If I made changes on another computer (such as adding new files) and push to git repo, then pull these into yet another computer then push back to git repo then push to heroku, would my changes on the first computer (the new file for example) deploy correctly to heroku?
Related
I'm new to programming, learnt languages but this part I have no clue.
I'm working on a app that is on bitbucket and on Heroku cloud.
I am not exactly very clear how the bibucket repository interacts with Heroku and also my local offline commandprompt+sublimetext+PG database.
So what I'm doing is i have made some changes physically on Bitbucket (manually on their website) based on the changes Ive made and viewed (offline on localhost 3000) and wanted to push it to Heroku to have the changes online. There does not seem to be any buttons on bitbucket for that purposes and I guess I have to do it through the command prompt.
In that case how do I make those changes (command lines) and update the sublime+PG on the local server? I seen a few codes on git and suspect those are it (like git push -v) which lists the repositories but I don't wish to test and end up screwing the codes. Please advise if there are easier to do any of the above.
Note that I want the changes to be on Heroku because of this error.
Rails 4 Relationship Issue extended
Also what the difference between pulling and pushing changes? I'm reading the git definitions but it isn't saying much. Just that pull is pulling data from other repository to I'm not sure where. Push is to update remote refs with associated objects.
Many thanks!
Because you're new, let me explain what you need:
Heroku uses an amazing deployment process which based on the git scm
system. This means that you just need to "push" your git
respository to Heroku in order for it to deploy your latest revision
of code
The problem you cited is you're trying to push from bitbucket
directly. Bitbucket / github are essentially just cloud
repositories where you can store your code, and is not where Heroku
can "read" your files from
To get this working, as you've stated in your comments, you need to push from your computer. This is achieved by creating a remote repository for Heroku, and then pushing to that, like this:
$ git remote add heroku git#heroku.com:yourherokuapp.git
$ git add .
$ git commit -a -m "Latest Commit"
$ git push heroku master
I currently have a remote to an EC2 instance set up on on my local git repo. The push works.
git push remote_name master
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (12/12), 896 bytes | 0 bytes/s, done.
Total 12 (delta 6), reused 0 (delta 0)
To user_name#dns:eko_web.git
4342c41..7bbc7db master -> master
When I ssh into the remote EC2 I can find the very first push I made copied over my app to var/app/current/ but no further updates. When I look in my bare git repo I find my most recent pushes when I do git show HEAD:<some_file>. When I manually edit the view in var/app/current the change isn't reflected in my website; the same initial push is all I see. I have a hook set-up in the post-receive of the bare git repo that is the following:
#!bin/sh
GIT_WORK_TREE=/var/app/current git checkout -f
As a broad overview, I used the following tutorials to get me this far. http://myrailslearnings.wordpress.com/2013/02/19/getting-ec2-to-use-git-for-rails-app/ http://www.lovholm.net/2013/06/26/push-your-code-onto-your-ec2-instance-with-git/
Thanks for any thoughts on this!
Edit:
Per Rico's suggestion, I started a new instance that hadn't been initialized with Beanstalk. I now have a git repo on the instance that (when updated manually) reflects changes on the server. But I'm still having problems pushing remotely to that location; it shows a successful push but then the files are there but not committed. If I commit them manually and then restart the server the website is updated.
There are many ways you can do the deployment. Deploying by pushing directly to a non-bare git repo can be done but it's not that common. (Like http://www.lovholm.net/2013/06/26/push-your-code-onto-your-ec2-instance-with-git/ describes) There are things that you have to watch for. For example you cannot push to a remote repository branch if that branch happens to be checked out.
From the looks of it you were deploying through Elastic Beanstalk initially or something because /var/app/current is the default location where it deploys Rails apps (when you do a git aws.push) Keep in mind that in a regular Elastic Beanstalk deployment /var/app/current doesn't hold a git repo. It's just a copy of your code (The git repo is saved somewhere else, I believe in S3)
The most common way of deploying from git is to have your git repo in github, bitbucket or a git repository in the cloud. Let's say you use github. At deploy time you would push to the github repository and then the new code gets deployed by cloning or pulling from the github repository into your cloud server. Capistrano is one of the tools that automates this process.
Another way of deploying is pushing to a bare git repository in the same say EC2 server where you are deploying and then pull/clone from that bare repository into another non-bare repository in the same server.
In your case you can also try switching your remote repository to non-bare if you want to see the code there. Easiest way I guess is deleting your bare repository and then cloning the original as a non-bare repository and sticking it where you want to deploy your code.
Here is the scenario:
1) My project partner and I were working on a Ruby on Rails app together using github as our code repo.
2) The app is under her github account and she had added me as a collaborator
3) She deployed to Heroku and added me as a collaborator there as well
4) I used the following command from my existing app directory with the intention of adding the existing Heroku remote app as a remote to my existing local app. My existing local app, as I mentioned before, already had a remote github
git remote add heroku git#heroku.com:codefellow.git
5) I made some changes and pushed them to github and all was up to date
6) Then I attempted to push to heroku with the following command
git push heroku master
7) This gave me an error saying the tip of my branch was behind, as shown below, but when I tried to pull from github, it said I was up to date, as also shown below
➜ code-fellows-alumni git:(master) git push heroku master
To git#heroku.com:codefellow.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#heroku.com:codefellow.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
➜ code-fellows-alumni git:(master) git pull
Already up-to-date.
So does anyone know what is going on here? How could my local branch be out of sync with Heroku if I'm up to date with Github? Would it have been possible for my project partner to have pushed changes to Heroku without having pushed them to Github first? I checked and she does not have a fork of the application. I cannot get in touch with her at the moment to find out for sure what she might have done--I'm not even sure it would allow her to push changes to Heroku if they hadn't been pushed to Github yet. Any insights would be much appreciated. I don't want to clone the app from Heroku necessarily because I already have it locally synced with Github. I want to use Github as the code repository and I am reluctant to start from a clone from Heroku. I've already looked at the Heroku documentation on this: https://devcenter.heroku.com/articles/git. It just says to do a clone but I don't want to do that for the aforementioned reasons. I followed the directions given in the answer to this question (How to link a folder with an existing Heroku app) to get this far but it seems like there is a missing piece or else my project partner has done something unusual. Thanks in advance for any helpful ideas you might have.
The message you are seeing means that changes have been made to the application that you do not have in your local copy. When you push it's rejected because the Heroku remote is further ahead than yours, so you're right in thinking that your partner has pushed to Heroku without pushing to Github - it's a common scenario since you deploy from your local repository when you deploy to Heroku, unlike a traditional Capistrano deploy which would deploy the code from Github typically.
It's down to you as a team to come up with ways of working which prevent this from occuring, but if you need to get working right now, you can either
git push heroku master -f. This forces your changes and will overwrite what's there presently with your code
git pull heroku master to pull the changes from Heroku into your local repo which should then let you do a git push heroku master when you have the changes.
I'm working on a rails app that I occasionally push to a staging server to test things out. I can easily push my local master to the remote master (I called it origin). I'm running into a problem where I'm trying out 2 frameworks, each in their own branch on my local machine. I'd like to see how the frameworks work on the remote server.
How can I push from local:Framework1 to remote:master (because the staging server has scripts that deploy master from the staging server's git repo)?
git push origin Framework1:refs/heads/master should do the trick.
Merge Framework1 into local master, then push origin master. You'll need to perform a clean merge locally before you start mucking up the remote server anyway.
Rails/Heroku/Git newbie - here is my question. I have an app deployed with Heroku and am using the git repository hosted there as the only remote copy of my local work. I start making changes locally on a new branch and want to make this branch available on Heroku so that I can continue work on it from another computer. Heroku ignores branches other than master and I don't want to merge my changes yet (or push them as master). Is there a way to store/access my new branch via my Heroku git repository, or is it better to have another remote git repository for my work in progress.
Thanks!
You can push a local branch to the remote git server with:
git push origin branch_name
That way, you can pull it down again elsewhere with:
git checkout -b branch_name origin/branch_name
http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html
http://gitready.com/intermediate/2009/01/09/checkout-remote-tracked-branch.html
I would go with a separate git repository as suggested - github.com or similar. Store your code there and deploy to Heroku's master repo - Heroku is a hosting platform afterall not a home for your repos.
ALTERNATIVELY Make use of dropbox and create your local workspace in a dropbox folder that is synced across multiple computers - I employ this method as well as git - plus you get the advantage that Dropbox is versioned so if you delete/change a file that you haven't committed yet you can get it back.