#Creating SSH folder and generating keys
On the previous page we discussed how we can work locally with the files and manipulate them within the folder. Let’s talk about remote tools, such Github. We will start from creating the folder for SSH:
$ mkdir .ssh
$ ssh-keygen -t rsa -C “firstname.lastname@example.org”
After that, the terminal will ask you to set the default location to save the files, the default works fine for us, hit enter and set the passphrase, highly recommended! Now, if we say $ls -al, we will see all of the list of the files within this director, including the hidden files. We are looking for files with id_rsa and id_rsa.pub
The file with pub extension is the public key for the connection with Github. Let’s open it with any of your favorite code editors, in my case it’s going to be sublime: $subl id_rsa.pub. Great! This is the key that we are going to use on Github side, just copy it and login/register in to Github.
Go to settings, and paste the ssh key. After that, come back to the terminal and connect to git hub using the following command: $ssh -T email@example.com
#Remote repository reference
Next, set up the repository to that was already created, select ssh option and copy the terminal command that was offered by Github: $git remote add remote-name remote-repository-location, in my case it’s $git remote add origin firstname.lastname@example.org:pandoraxcc/git-demo.git
#Sending changes to remote (Github)
Here, the remote command allows to associate the remote repository and usually the first/primary remote will be called origin. We can see the list of git’s remotes by using this command: $git remote -v , where -v stads for verbose, displaying full lists of URLS of the remote repository. For the first push on remote, we will need to use -u parameter: $git push -u remote-name branch-name
Here, push sends all local changes on branch to the remote, listed here as remote-name. In my case, master is the branch, and remote is origin, the command will look like this: $git push -u remote origin master
#Receiving changes from remote
To receive all remote changes to our local branch, simply use this command: $git pull remote-name branch-name, in my case $git pull origin master
That’s it! Now, we can freely interact with local and remote environment! Cool! There is a cool book about git for free, try it out!
proudly runned on WordPress