GIT push with SSH - github

I am having create difficulty finding reliable information on creating SSH keys in order to remove the need for username and password when doing git push and pull for a main repo and separate nested repos.
To make sure I have no existing errors deleted them from
https://github.com/settings/keys
And then followed this guide which in a nutshell advises:
Check for existing, I deleted all from here as well
ls -al ~/.ssh
then (accepting defaults with no passkey)
ssh-keygen -t rsa -b 4096 -C "your_email#example.com"
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
clip < ~/.ssh/id_rsa.pub
and pasting key at https://github.com/settings/keys
The guide seems to end here, however attempt to push the repo gives:
fatal: HttpRequestException encountered.
An error occurred while sending the request.
Username for 'https://github.com':
What steps have been missed here please.
Attempting to push via git bash

Related

Upload file by git lfs correctly

I tried to upload large file ( 240mb ) to github by lfs by using
- git lfs install
- git init
- git remote add origin "my repo url"
- git lfs track "*.weights"
- git add yolov3.weights
- git commit -m "test"
- git push -u origin master
after uploaded i found the file content
versionversion https://git-lfs.github.com/spec/v1
oid sha256:c49c28814dc8bcd2c48aac1c3e41c92a183cf9b282f6ca4c05f3d99393137952
size 246305388
And not working but the size still 240 mb
How to upload the file right or what is the wrong?
Did you try pushing the code using this command ?
git push origin <branch name> --force
HTTPS protocol can sometimes be unreliable when it comes to pushing large files . It may break unexpectedly
why dont you try pushing the code via SSH method ?
Run these commands below ::
ssh-keygen -t rsa -b 4096 -C "<email id>"
notepad ~/.ssh/<required key>.pub
// paste this public key into your github account
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<required_key>.pub
You can learn more about the ssh protocol in this article

Start ssh-agent when windows boots along with ssh passphrase

I have a private Github repo, and I generated the SSH keys using windows.
I am trying to launch ssh-agent when my windows server starts, I can have the following command..
start "" "%PROGRAMFILES%\Git\bin\sh.exe" --login -i
but the problem with this is...I would need to enter the passphrase for my SSH key everytime i reboot.
I am working with a github repo, where whenever we commit a change then it triggers the GIT PULL on the server (using webhooks).
Anyway I can automate this?
You could make sure your .profile (called by sh --login -i) includes a call to ssh-agent with a file:
cat passfile | ssh-add -p keyfile
That way, every time the shell starts, the agent includes your key with its passphrase.

SourceTree Terminal prompting for password but repo authentication is done via SSH

I'm running into an issue where whenver I try to open the terminal for a repository in Sourcetree and I perform a command e.g. git push, I am prompted for a password. The weird thing is that the repository authentication is done via ssh. The normal controls in the GUI work fine for pulling/pushing and doesn't prompt me for a password.
I have set up SSH configuration like so (which works fine for the regular Sourcetree GUI):
As per this thread with a similar issue: https://community.atlassian.com/t5/Sourcetree-questions/ssh-key-in-sourcetree-terminal/qaq-p/137178 I have copied the privkey.ppk to C:\Users\Niels\.ssh\.
Pageant shows the private key as being added too:
Why can I not perform Git operations on my repository from the terminal?
Git uses different format for keys than pagent and pagent is only usable for SourceTree not for Git system. You have to generate a new ssh key with ssh-keygen and you have to add that key to git server you want to use. Open a terminal (GitBash) and apply the following steps:
cd ~/.ssh
ssh-keygen -t rsa -C "your.email#example.com" -b 4096
cat id_rsa.pub | clip
Last command would copy the new public key to the clipboard. You can add it to Git server just bye pasting in the mentioned text box.

Auto push to github without username and password

after much messing around I have followed this tutorial on using a cmd prompt to push up to git hub
http://readwrite.com/2013/10/02/github-for-beginners-part-2
However I have had to do a few things differently. Generating and adding the public key in GitHub went fine, however, adding the private key on my local machine has been a real pain.
I finally added it by opening a cmd prompt as administrator. then going to the directory where github was installed I then rand the following cmds to install the private key
bash
eval $(ssh-agent)
cd to-directory-where-private-.ssh-file-was-located
ssh-add .ssh
Identity added: .ssh (.ssh)
Prior to that I had numerous errors. However, when I run this from a batch file
cd c:/LocalDevelopment/PhoneGap/PfpMetrol
git init
git status
git add PhonegapData.js
git commit -m "Add PhonegapData.js"
git remote -v
git push
pause
it is still asking me for a username and password.

Uploading Folder with images to github

As the title states I was uploading my project to github ( https://github.com/siddhartha-ramesh/FilmReview.git ), but I am stuck here. I cant upload a directory called img to github can anyone help me how to do that. I am not using any gui. Can I create a new folder in github.com just the way I can create new files?
This is what that is happening:
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git#github.com:siddhartha-ramesh/FilmReview.git
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ cd ~
siddhartha#siddhartha-Inspiron-545s ~ $ cd .ssh
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ ssh-keygen -t rsa -C "siddhartharamesh#gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/siddhartha/.ssh/id_rsa): key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in key.
Your public key has been saved in key.pub.
The key fingerprint is:
#key here
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cd /home/siddharhta/.ssh
bash: cd: /home/siddharhta/.ssh: No such file or directory
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cd /home/
siddhartha#siddhartha-Inspiron-545s /home $ cd *
siddhartha#siddhartha-Inspiron-545s ~ $ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
siddhartha#siddhartha-Inspiron-545s ~ $ cd ..
siddhartha#siddhartha-Inspiron-545s /home $ ls
siddhartha
siddhartha#siddhartha-Inspiron-545s /home $ cd siddhartha/
siddhartha#siddhartha-Inspiron-545s ~ $ cd .ssh
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ ls
key key.pub known_hosts
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cat key
-----BEGIN RSA PRIVATE KEY-----
-----END RSA _________________
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ ls -a
. .. key key.pub known_hosts
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cat key.pub
ssh-rsa
#key here
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cd ..
siddhartha#siddhartha-Inspiron-545s ~ $ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
siddhartha#siddhartha-Inspiron-545s ~ $ cd Desktop/
siddhartha#siddhartha-Inspiron-545s ~/Desktop $ ls
Aptana_Studio_3 C_C++ Codes key Untitled Folder WS
siddhartha#siddhartha-Inspiron-545s ~/Desktop $ cd Untitled\ Folder/
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ ls
film_review
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git#github.com:siddhartha-ramesh/FilmReview.git
fatal: remote origin already exists.
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
To git#github.com:siddhartha-ramesh/FilmReview.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:siddhartha-ramesh/FilmReview.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.
If you have your folder with your files (pictures in this case) in your local repo (cloned of your github repo), all you need to do to see that folder on GitHub is:
cd /path/to/that/folder
git add .
git commit "add folder with pictures"
git push
# or, if this is your first push:
git push -u origin master
In other words, you add all the files in that folder, and push them.
Instead of trying to add a remote, clone your GitHub repo first, add content in the local clone and push.
Don't use ssh first, use a simpler url based on https, and your login/password:
git clone https://siddhartha-ramesh#github.com/siddhartha-ramesh/FilmReview
cd FilmReview
git config user.name siddhartha-ramesh
git config user.email (your email address used on GitHub)
# add your files
git add .
git commit -m "Add folder"
git push -u origin master
# the next push can be simply 'git push'
GitHub's UI in this respect has not changed in all of these years. If you want to add directories via the GitHub UI, you have to do this:
Select Add file.
Don't pick upload file like you'd think. Instead, select "Create new file".
Up at the top where it says your project name, you should see "Name your file...". Instead of typing the name, type the directory name you're wanting to add and instead of hitting enter, type "/".
Now you need to either add a real file to that directory or just create a fake file name with fake contents. In my case, I just titled it "test.js" with "test" on line 1.
Now, you need to commit the file.
GitHub will create a directory and will upload your new file.
Now if you want, you can delete the test file and your new directory will remain.
Caveat: I'm not sure if you can create a nested directory two levels deep using the "/" trick or not.