Ruby on Rails tutorial chapter 1.4.3 (part about bitbucket) - ruby-on-rails

I'm having some trouble setting up the bitbucket repo
humantoast#rails-tutorial:~/workspace/hello_app (master) $ git remote add origin git#bitbucket.org:HumanToast/hello_app.git
fatal: remote origin already exists.
.
humantoast#rails-tutorial:~/workspace/hello_app (master) $ git push -u origin --all
conq: repository does not exist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I just want to say that I tried the following and it seems to have worked. Note that '<username>' refers to your username. If on a numbered list, replace <username> with your username.
Enter the numbered commands below into the terminal. 'Result' is the output the terminal showed after the command was entered
git remote -v
Result
origin git#bucket.org:/hello_app.git (fetch)
origin git#bucket.org:/hello_app.git (push)
git remote rm origin
Result
No output in the terminal
git remote add origin git#bitbucket.org:<username>/hello_app.git
git push -u origin --all # pushes up the repo and its refs for the first time
Result (note the 3 dots below refers to output on the terminal that I excluded due to it potentially containing confidential information)
.
.
.
Are you sure you want to continue connecting (yes/no)?
yes
Result
.
.
.
To git#bitbucket.org:<username>/hello_app.git
[new branch] master -> master
Branch master set up to track remote branch master from origin.
That seems to have done the trick. I wasted a day stuck so early in the book.

Related

Github pulling does not work in - Rails 5

I'm trying to pull last commit that I made on github, and though I get no errors, I see no changes in the code. I messed up my schema file, but after I pull the code it does not change at all.
I searched here on stack and the solution that worked for others didn't work for me, and this is also my first time that I'm pulling code from github, so I could've probably done something wrong.
I used this code:
git fetch origin controller-generator
git git reset --hard FETCH_HEAD
This is what I get as the output
HEAD is now at 1fb8c97 Integrated friendly routes gem
'Integrated friendly routes gem' is my last commit that I want to pull, but nothing changes. I don't know if I need one more step or whatever it goes with it.
This is what I have in commit db file
And when I pull this, I get this
The last one should not be there.
This is output
equalsign:~/workspace/BlogAndPort/db/migrate (controller-generator) $ git reset --hard 1fb8c97d64f389904b3048fb2850fcfd8425cd36
HEAD is now at 1fb8c97 Integrated friendly routes gem
equalsign:~/workspace/BlogAndPort/db/migrate (controller-generator) $ git push -f origin HEAD
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Everything up-to-date
The problem is still the same as shown in the pictures. db files did not change
If I understood, you are asking to reset your local/master with origin/master.
$ git fetch
$ git reset --hard origin/master
You can back (hard reset) to a commit that was working for you.
$ git reflog # copy the commit-sha where you want to back/reset
$ git reset --hard <commit-sha> # reset to the commit
Now, if all things are ok. Then Force (-f) Push to remote.
$ git push -f origin HEAD # update remote branch

Git push origin master fatal error: Permission to railstutorial/first_app.git denied

I'm trying to git push origin master using Michael Hartl's rails tutorials (first_app), but i'm getting this problem:
[first_app]$git push origin master
ERROR: Permission to railstutorial/first_app.git denied to tomkim
fatal: The remote end hung up unexpectedly
I've re-entered an SSH key, but that's not it. I've never had this problem before, but now I am.
Help's greatly appreciated.
You need to add your own repo as the remote (of course you need to create a first_app repo on Github first):
$ git remote rm origin
$ git remote add origin git#github.com:tomkim/first_app.git
$ git push -u origin master
And tomkim is your github account name, right? If not, change it to yours.
I was able to figure this out. I noticed that the origin was showing "railstutorial/first_app.git", when that it should've been tomkim310/first_app.git. The problem to begin with was follow Hartl's tutorial, I was just typing as he was going. Simply doing a new "git remote add origin git#github.com:tomkim310/first_app.git" does not do the trick.
I verified this by typing in: git remote -v which gave origin git#github.com:railstutorial/first_app.git. To change it, i typed: git config remote.origin.url git#github.com:tomkim310/first_app.git.
This then did the trick and git push origin master worked.

Rails/Git: can't push my rails code out to the server ('~/git/myapp.git' does not appear to be a git repository)

I'm new to rails and git. I have a rails application under ..../myapp that I would like to deploy using capistrano. I followed the steps described in "Agile Web Development with Rails". To put the application under version control, I did the following:
1) Put my application under version control:
$ cd myapp
$ git init
$ git add .
$ git commit "..."
That all went fine, it created a .git directory under myapp/
2) Created an empty repository on the server:
$ mkdir -p ~/git/myapp.git
$ cd ~/git/myapp.git
$ git --bare init
$ Initialized empty Git repository in /root/git/myapp.git/
3) Created a public key
$ ssh-keygen -t rsa -C "myemail#myemail.com"
$ Your identification has been saved in /root/.ssh/id_rsa.
$ Your public key has been saved in /root/.ssh/id_rsa.pub.
$ The key fingerprint is:
$ d2:16:76:e0:4c:71:de:de:4b:d3:16:94:cc:d7:65:11 myemail#myemail.com
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
4) From my application directory: created the path to the server and push the code
$ git remote add origin ssh://me#host/~/git/myapp.git
$ git push origin master
Now I'm being asked to enter my password, after that:
$ fatal: '~/git/myapp.git' does not appear to be a git repository
$ fatal: The remote end hung up unexpectedly
It might be worth noting that this all happens on the same server, a RHEL 5.7. This is something that confuses me because I basically ssh from my server onto my server. But apparently that's how capistrano does it, even if the application_development and the svn repository are on the same physical machine.
# manojlds:
$ GIT_TRACE=2 git push origin master
$ trace: built-in: git 'push' 'origin' 'master'
trace: run_command: 'ssh' 'me#host' 'git-receive-pack '\''/root/git/myapp.git'\'''
Pretty sure you don't want the tilde ~ in the path. I'd put the actual path in (eg /home/users/)
It is possible that using a relative path and specifying the ssh portion is causing it to break when adding origin.
Try something closer to this:
git remote add origin user#myserver.com:/var/git/myapp.git

Change github repository for Rails

How do you change the git repository a rail app is pushed to? I know that this is possible because I did it a few weeks back.
Basically I have two very different versions of a app on my local machine. I would like the initial app to still point to the old repository. However, the new version needs to be placed in a completely separate repository.
When I run git init in myapps/old_app/ it puts Reinitialized existing Git repository in /Users/jamespollard/rails/old_repository/.git/
AND
When I run git init in myapps/new_app/ it puts Reinitialized existing Git repository in /Users/jamespollard/rails/new_repository/.git/
However, when I try and git push anything to the repository, it still goes to the old_repository.
Updates
If I enter $ git remote origin set-url git#github.com:mygithub/myapp.git
I get
error: Unknown subcommand: origin
usage: git remote [-v | --verbose]
or: git remote add [-t <branch>] [-m <master>] [-f] [--mirror=<fetch|push>] <name> <url>
or: git remote rename <old> <new>
or: git remote rm <name>
or: git remote set-head <name> (-a | -d | <branch>)
or: git remote [-v | --verbose] show [-n] <name>
or: git remote prune [-n | --dry-run] <name>
or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
or: git remote set-branches <name> [--add] <branch>...
or: git remote set-url <name> <newurl> [<oldurl>]
or: git remote set-url --add <name> <newurl>
or: git remote set-url --delete <name> <url>
-v, --verbose be verbose; must be placed before a subcommand
If I enter $ git remote set-url git#github.com:mygithub/myapp.git I get the same error message as above (minus the origin error). In either case, if I run git push origin master it still pushes to the old repository. I've tried adding the new repository again with the same name, but I get a error (which i would expect) saying that it already exists.
Create a new repository in GitHub for you new app, if you haven't already. Make that new repository as origin to your new repository:
git remote add origin <github_url>
If the remote already exists, you might have to git remote set-url origin <github_url>
Now, push to the repo.
I ran into a pretty similar situation few months ago. On the new version of the app there is a .git folder (which was also copied along with all other files when you copied the app). Heroku needs the information from .git to see if anything has changed. So when it 'reinitialized', heroku thinks its the same app.
So here's what I did that resolved the problem.
Copied the entire app folder.
Changed app name wherever they appear (mostly in config folder, google it for a list)
Chang secret.yml file (get a new key by rake secret) or secret token if older version
of rails.
Most importantly, there should be a .git folder in your app folder (it maybe hidden).
Delete that .git folder (it contains git info of the old app)
Initialize a new git, git init
and then commit and push.
Your new app should be a separate app now.
I think this might work if on heroku, worth a try:
git remote rm heroku
git remote add heroku git#heroku.com:yourappname.git
or you can try this
1). open a terminal
2). Go to your_app_directory/.git/config
3). Once you open the config file then edit as follows:
Change
url = git#heroku.com:old_app_name.git
to
url = git#heroku.com:new_app_name.git
Obviously substituting your apps old name to its new name. Hope it helps
If you take a peek at your .git/config file, you see / check that the url is still pointing to the old remote
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = <old_github_url>
so you wish to keep the old remote. let's call that oldremote.
First thing you can do is the rename the remote with :
git remote rename origin oldremote
Now you can add the new remote with :
git remote add origin <new_github_url>
From now on, pushing normally with just git push will push to the new remote. git push oldremote SHA to push to the old remote
remote reference : http://help.github.com/remotes/

Ruby on rails and Heroku problem

$ git push heroku master
I basically get this error message.
error: src refspec master does not match any.
error: failed to push some refs to 'git#heroku.com:falling-stone-505.git'
I'm very new to computer programming and ruby on rails so an "idiots" guide to solving this would be appreciated.
Thanks in advance.
You haven't committed anything to push yet. Try doing:
$ git add -A
$ git commit
Then try to push to Heroku again.
You might try following along with this tutorial, although I can't vouch for it. Most of the professional endeavors in this space are books.
If you want your commits to be easier to track in the future, after
1.
$ git add -A
2.
instead of
$ git commit
you can use
$ git commit -m "add a message here such as FIRST COMMIT or PROBLEM WITH CONTACTS VIEW ADDRESS VARIABLE TYPO FIXED."
3.
Then you can
$ git push heroku master

Resources