Issue trying to push to git repository - ruby-on-rails

Problem when pushing app to github. This is what I entered into the command line. Hopefully it's just a small problem I can fix thanks.
git init
git add README.md
git commit -m "first commit"
git remote add origin git#github.com:travi5567/first_app.git
git push -u origin master
This is the error I get:
Traviss-MacBook-Pro:sample_app Travis$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

If you don't know how to use SSH keys or would rather not you can also use the https remote like so:
git remote add origin https://travis5567#github.com/travis5567/first_app.git
git push origin master
Password for travis5567: <enter your password>
# regular output from a git push

GitHub uses SSH keys to configure access to git repositories. If you are the owner you can push to the repo but you need to tell git your SSH key so they know who you are first.
It's all explained on the GitHub website - https://help.github.com/articles/generating-ssh-keys

Related

Laravel + Angular project commit error: src refspec master does not match any

There is a project that is coded using angular and laravel. I downloaded it from server to my local. After doing some cleaning, tried to commit to git. But I see the same error everytime which I specified on header.
After some tests, when I was looking here for the same errors, I couldn't find any solution. There are my steps:
1. cd sysGarden
2. git init
3. git add .
4. git commit -m "first commit"
5. git remote add origin git#github.com:biyro02/sysGarden.git
6. git push -u origin master
After the last step I saw errors. I have an account on github. You can look: https://github.com/biyro02/sysGarden
On git bash, I have logged in with my user name and password. Everything ok but I see errors. Please help me. This is my first git commit. I am ready to share my all infos. Just, I want to exceed this problem.
Edit: I execute "git branch" result: * master
Edit 2: I got the error below:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
You should be able to resolve this issue by running the following commands again.
git add .
git commit -m 'Commit Message Here'
git push -u origin master
You may also try git push origin HEAD:master and if you need more information to share you can try git show-ref to see more verbose your local branch information.
This issue likely happens because of unstaged / untracked files or because your current branch is different to the branch you are pushing but I cannot be certain.

Multiple Bitbucket accounts on same machine

I need to implement multiple bitbucket accounts on same machine.
I set user name and email locally but did not work
git: 'credential-[here show global user]' is not a git command. See 'git --help'.
remote: Unauthorized
fatal: Authentication failed for 'https://username#bitbucket.org/xyz/xyz.git/'
I resolve this issue by setting my remote url with my password
here you can check
git remote -v
origin https://USERNAME#github.com/REPOSITORY.git (fetch)
origin https://USERNAME#github.com/REPOSITORY.git (push)
now set your remote url like this
git remote set-url origin USERNAME:password#github.com/REPOSITORY.git
that it now on every command git never ask you about password

Digital Ocean git bare repo

I am trying to setup my own production environment on digital ocean with ubuntu, rails and git.
I have followed this and this tutorial among others.
They all instruct to create the repository as bare, i.e.:
mkdir site.git && cd site.git
git init --bare
Problem is that when I push from my local computer, I got the error:
This operation must be run in a work tree
I looked into it and it seems that the cause is that the repo is bare.
In my post receive file I have:
#!/bin/sh
git --work-tree=/home/rails/myapp --git-dir=/var/repo/site.git checkout -f
So I am confused. I suppose that I could initialize the repo as non bare instead. But why every tutorial suggests to initialize it as bare if then it causes that error?
If you are making a git push, you must do so from a normal git repo, meaning a local repo on your workstation (pushing indeed to a bare repo)
cd /path/to/my/local/repo
git init .
git add -A
git commit -m "my first commit"
git remote add origin /usr/bare/repo
git push -u origin master
In your case, you cannot push directly from where the post-receive hook does a checkout, unless you mention in your git push command where the git repo is (bare or not)
cd /home/rails/myapp
git --work-tree=/home/rails/myapp --git-dir=/var/repo/site.git push -u origin master
(and this assume /var/repo/site.git does include a remote named origin)

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.

How to push existing source code to a repository in github?

I have a rails app hosted on heroku and i want to push the code to github(Aready created a repo on there).I tried to follow the steps in this question .Since i already have a local repository and currently can push and pull from heroku i skipped step 2 and 3 .But when i do step 4
git remote add origin git#github.com:sparkz19/stark-journey-1727.git
It says
fatal: remote origin already exists.
And when i do git remote -v
It says
origin git#heroku.com:stark-journey-1727.git (fetch)
origin git#heroku.com:stark-journey-1727.git (push)
What do i need to do here?Thank you in advance.
Git complains because origin is already defined. If you still want to keep the heroku remote you could use git remote rename to save it as another remote:
git remote rename origin heroku
Reset the url with git remote set-url:
git remote set-url origin git#github.com:sparkz19/stark-journey-1727.git
Now you can push and pull to any you like:
git pull heroku master
git push origin master
Just give your new remote a different name than origin and you'll be good to go.

Resources