Why can't I see my remote git repositery? - ruby-on-rails

Here is what I did:
Created a Ruby on Rails app.
Initialized empty git rep
Made changes to my app and saved them (git add -A and git commit -m "blahblah")
Deployed to Heroku.
But when I visit git hub it shows zero repos?
What did I do wrong?

I think you confound github and heroku.
It's two differents repository.
Deploying to heroku with something like this:
git push heroku master
does not affect your github account.
You can have several repository for the same project.
To add a repository:
git remote add NAME_OF_YOUR_REPO URL_OF_YOUR_REPO
(you can create a project in github, and they will git you a URL_OF_YOUR_REPO)
example:
git remote add origin https://github.com/user/repo.git
after you can do:
git push origin master
and you will see your commits on github.

Related

heroku staging - not able to push

I am not able to push to staging for heroku.
When I am doing git remote staging master I am getting
fatal: 'staging' does not appear to be a git repository
fatal: Could not read from remote repository.
Although I used to push to staging using the same command.
git remote -v
returns
origin git#bitbucket.abc/test.git (fetch)
origin git#bitbucket.org:abc/test.git (push)
I tried to add a git remote, but It created something else and when I did git push staging master, It created another url of the app instead of pushing for the earlier staging url.
I am not able to resolve this. Also I am the owner of the heroku app.
There is only one git repo configured here, and that is a bitbucket git repo. You need to add the heroku configuration too. See this link for reference.
Ultimately, run something like heroku git:remote -a heroku-app-name -r staging. Then you can do git push staging master and it'll push to the given app.

created bitbucket repo deleted it, created again, git remote push fails

I am using cloud9 IDE on a rails tutorial app. I created a repo and then pushed the app to the repo on bitbucket. I got messed up on the app so decided to start from beginning. I deleted the repo and worked on the app until it worked. I created another repo on bitbucket and did all commits and when I did these I got a message saying I was three or five commits ahead of remote. So when I did a push I got
git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
Everything up-to-date
If you don't mind starting from scratch and losing your app's history.
Create a new repo on Bitbucket.
Next, remove the .git directory from your local project.
Then initialize a new git repo locally
git init
git add --all
git commit -m "Initial commit"
On Bitbucket you'll see a screen like the one below.
Now just run the commands as exactly as it instructs
cd /path/to/my/repo
git remote add origin git#bitbucket.org:your-username/project.git
git push -u origin --all
git push -u origin --tags
Then everything should be reset without any history.

How can i sync my repository with github?

simple example,
1)made a new project
rails new test_app
2) git commands
git init
git add .
git commit -m "init"
git push origin master
ok finished!
now after this, if i look at github.com webpage gui.
it doesn't show my repository.
How can i set this to my github webpage?
First of all you need to create an repository on github. After that you need to create an ssh key with github for your pc. Befor you can push to the master branch you need to add the remote repository:
git remote add origin git#github.com:yourrepo.git
Than push "origin" to the master branch.

Can't push master branch to Heroku in Git

I am collaborating on a project and cloned the repo from Github, made some changes and pushed to Heroku. Now the cloned app had all of its keys and passwords hardcoded, not in ENV variables.
So I created ENV variables, added the file to .gitignore. So this app still has these keys in the commit history. What I have done now is have the author create a new repo on Github, remove .git file from original app and push new code to new repo.
So now I have cloned the new app, added a new remote the the Heroku app.
heroku git:remote -a myapplication
My issue is I cannot push the new app to the existing Heroku app. When I do I get:
error: failed to push some refs to 'git#heroku.com:myapplication.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.
So a git pull says everything is up to date.
git remote -v outputs
heroku git#heroku.com:myapplication.git (fetch)
heroku git#heroku.com:myapplication.git (push)
origin git#github.com:author/myapplication.git (fetch)
origin git#github.com:author/myapplication.git (push)
What can I do to push the new application to the existing heroku app?
Update
I ran
git push -f heroku master
which pushed but I had error
you have not declared a Ruby version in your Gemfile.
To set your Ruby version add this line to your Gemfile:"
ruby '1.9.2'"
I've never had to specify before, and now all the original config vars that where set are no longer stored in Heroku.
git pull would pull by default from GitHub, which has all your commits already.
You might need to:
git pull heroku
clean-up the files (if the merge brings back the hardcoded values)
push to origin
push to heroku through the heroku command.
Git uses the concept of tracked branch to know which remote branch is linked to a local branch.
In your case, you probably have your local branch (I suppose it's master) linked to origin/master. So, when you do a git pull, Git is trying to get new stuff from git#github.com:author/myapplication.git, which is not the wanted behavior.
You have to change your tracked branch using :
git branch --set-upstream-to heroku/my_branch
Then, you can do a git pull which will now have the wanted behavior. Then just push to heroku, as you always do.

Heroku upload changes

I make some changes in local files, how can I deploy the new version?
if I type git push heroku master, it's say everything up to date, but the application wasn't changed.
You probably need to commit your changes first.
Run git commit -a -m "updated some files"
then run git push....
So you’re on a git repo with a remote repo named heroku?
Did you commit your changes, and afterwards push?
They have to be commited locally so you can push them.
When you clone a repository with git the remote repository you cloned from will be added as “origin”, then a simple git push will push to the origin.
If that’s not the case, you can use the name of another/your remote repository you added first, or it’s URL.
Also see the doc for git push: http://www.kernel.org/pub/software/scm/git/docs/git-push.html

Resources