Is there any way to recover my application in ruby on rails if I have a copy at the git repository? - ruby-on-rails

I have stupidly named a new web_app the same name in my ruby on rails directory.
And now I tried to look back the "blog" in the browser, all is gone.
Now, I have a copy of the application in git repository.
Is there anyway I can pull it down to the command prompt in my computer?
Hope someone can advise me how to.
I have so far tried git pull origin master and the rails command prompts only said master -> Fetch Head
But, still nothing shows up in the browser when I type localhost:3000 etc..
Thanks.

You should be able to clone it.
Run the git clone command.
git clone (the url to your remote repository)
If you go to your repository on the right hand side of the page you will find the url to clone.

Related

Why is my app not pushing to bitbucket? (Michael Hartl's tutorial chapter 3 section 3.1)

I am following Michael Hartl's tutorial (chapter 3 section 3.1 https://www.railstutorial.org/book/static_pages) using cloud 9 IDE and trying to push the sample_app to bitbucket. When I type the following command into cloud 9 IDE:
Since we’ll be using this sample app throughout the rest of the book,
it’s a good idea to create a new repository at Bitbucket and push it
up:
$ git remote add origin git#bitbucket.org:/sample_app.git $
git push -u origin --all # pushes up the repo and its refs for the
first time
I get the following error
fatal: remote origin already exists.
(NOTE: I have changed username to my username).
Since I got the error I have tried several solutions including deleting everything from bitbucket fromt he previous exercises in the book. so far i have followed the instructions to the letter, although I did accidentally close some of the tabs in the command line on cloud 9 and I don't know if this made any difference. I also notice that nothing seems to have been created on git even though i did git init, git add -A and git commit. What have I missed. help is greatly appreciated so I can move on. Please let me know if there are any files I should add to an edit of this post. Thanks.
fatal: remote origin already exists.
The remote you're trying to add already exists. Run git remote -v and check in the ouput it gives to you, if is there, then skip the first command and pass the second one to push.

Bitbucket/Github: permission denied public key

when I am trying to clone a rails app repo I have got permission to, I am getting this issue.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Even after adding public key by generating one, I am unable to solve this.
Although I am able to clone using he https method but after making changes, the same error comes while I try to push the code.
Please suggest an answer for this.
First, cd into your .ssh directory. Open up the terminal and run:
cd ~/.ssh && ssh-keygen
Second, you need to copy this to your clipboard:
cat id_rsa.pub | pbcopy # On OSX
cat id_rsa.pub | xclip # On Linux
Third, add your newly generated ssh key to your account via the github/bitbucket website (just paste there).
Next, setup your git config:
git config --global user.name 'your_user_name'
git config --global user.email 'your_email'
Finally, restart your command line to make sure the config is reloaded.
Now, you should be able to clone and push from/to your github repository.
For more information on this, see this github page or this bitbucket page.
When attempting to clone, push, or pull over SSH with Git, you may receive one of these messages if Bitbucket couldn't authenticate with the keys that your SSH agent offered.
Here are the most common reasons why you may see these messages:
You used sudo when attempting the connection
You shouldn't use sudo when cloning, pushing, or pulling because the ssh-agent runs on the user level, not the root level.
Your public key isn't loaded into Bitbucket
To check if your public key is loaded into Bitbucket, do the following:
From Bitbucket, choose Personal settings from your avatar in the lower left.
The Account settings page displays.
Click SSH keys.
The SSH keys page shows a list of any existing keys.
If you don't have any keys listed, you can follow our Set up an SSH key documentation to set one up.
Your key isn't loaded into your SSH agent
If your SSH agent doesn't know to offer Bitbucket a key, the connection fails. You may run into this issue if you've recently restarted your system.
You can refer to this Article for more informations:
https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/
Check few things.
Is the generated new key is the one your ssh agent using when trying to ssh to server.
(Your ssh agent might be using a different key than the one you generated)
use this to list currently loaded keys by agent.
ssh-add -L
You properly added public key to your repository hosting location.
The keys corresponding to above 1 and 2 should match.
Please see this article: GitHub: Generating SSH Keys. What happens when you run:
ssh -T git#bitbucket.org
?
You may have added the wrong key to authenticate with.
I faced this error when I created another repository in my local. My ssh-keys were already set up and I was trying to push code through vs code.
The issue got resolved when I git push-ed through git bash like I was doing before.
For bit bucket I think I have tried everything with ssh. I have tried the answer from this stackoverflow question as well. But it doesn't work. So finally I just changed the clone command from SSH to HTTPS and it worked. Only then it asked for password for my account.

Xcode 7 GM can not authenticate git repository

I could commit to this repository without problem with Xcode 6. git still works fine in terminal, i can commit both locally and to the remote. In Xcode 7, I can commit locally but not remotely. it says authentication fails and it is impossible to reset the username. (it's greyed out). I have the proper username in my local git config file. I've also tried to create a new account but I end up with the same problem of not being able to enter the userName.
my git config --local --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=git#bitbucket.org:myUserName/myProject.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.failedTryToRename.remote=origin
branch.failedTryToRename.merge=refs/heads/master
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.master1.remote=origin
branch.master1.merge=refs/heads/master
user.name=myUserName
user.email=myUserName#gmail.com
The problem is that you are using the SSH remote URL:
remote.origin.url=git#bitbucket.org:myUserName/myProject.git
You will need to switch to the HTTPS remote URL.
git remote set-url origin https://bitbucket.org/myUserName/myProject.git
Alternatively, just give up. Stop trying to use Xcode's internal git management. (It's pretty terrible, so no harm done.) If you want a GUI, use SourceTree; it's from the same people who give you Bitbucket and works with it beautifully.

why does git recommits all files even the ones that I did not change

I am contributing to a project and forked their repository.
I have spent a few days on coding some new features and when I commit my changes to github every single fine gets recommited.... Even if I have not changed the file..
Why is this happening, I am new to vagrant and git.
My workflow is the following:
cd into the project:
/rails_projects/my_project
vagrant up
vagrant ssh
cd /vagrant
*****do some changes here to my code
git add .
git commit -m "asdfsdf"
git push
Is there something I missed with vagrant or git? I am on Windows running the suggested ubuntu virtual box. Maybe I had to create the virtual box in the parent directory instead of in the directory of my project? Or what is the deal? Or am i supposed to run the git commands from a different directory?
Thanks
So what ended up happening was that I had to do
cd ..
To get out of /vagrant file and then also
exit
To get out of vagrant ssh session.
Then I committed to github and everything was fine. Thanks!
To clarify for others.
It looks like you were trying to commit code from within your Vagrant box. As the OP has already found out, you don't want to do this (as the local Git repository is located on your computer, not inside the virtual machine Vagrant manages for you).
Personally, I have a terminal window open for Git and another open for Vagrant. This prevents the issue described in this question.
Bonus tip: If you develop using a Mac, you can hit Command + T whilst in Terminal to open a new tab. It's a shame you can't do this on Windows....

Heroku deployment error

In a windows environment I am getting the following error when trying to deploy to Heroku
C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/base.rb:32:in ': No such file or directory - git
remote (Errno::ENOENT)
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/ba
se.rb:32:in shell'
from C:/Ruby/lib/ruby/1.8/fileutils.rb:121:in
chdir'
from C:/Ruby/lib/ruby/1.8/fileutils.rb:121:in
cd'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/ba
se.rb:32:inshell'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/ap
p.rb:52:in create'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/command.rb:
48:insend'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/command.rb:
48:in run_internal'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/command.rb:
20:inrun'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/bin/heroku:13
from C:/Ruby/bin/heroku:19:in `load'
from C:/Ruby/bin/heroku:19
Any idea how I can correct this? This is being run from the Ruby Command line (which seems to me like the regular command line)
Ok so I figured out a way to make it work and why it is likely happening.
For some reason I can only run the Ruby commands from the CMD prompt however the GIT commands only seem to work from the GIT Bash. When in the GIT Bash the Ruby commands don't work.
When you run the Heroku commands to create the service it seems to want to run certain GIT commands which don't work from the CMD prompt the way I have it set up.
To get around this for the moment I am adding the Heroku path for GIT as a remote manually and then pushing that manually when needed. An extra step but everything still works as intended.
If you need help with the work around check out the information in this link: http://www.wiki.devchix.com/index.php?title=Working_around_the_%22heroku_create%22_error
I'd still recommend using Git Bash over the normal windows CMD prompt.. but I know how tedious that can be sometimes.
You can bypass the need to do this however and get your Heroku gem working properly in your windows CMD prompt by adding your msysgit/bin path to your system Path variable.
That'll give your heroku gem access to the git command.
To add heroku as remote use the following:
git remote add heroku git#heroku.com:yourappname.git
Then push your master copy to Heroku:
git push heroku master

Resources