Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Friday, February 27, 2015

How to generate SSH keys for Github in Ubuntu

SSH keys are a way to identify trusted computers, without involving passwords. 

To get the previously generated ssh keys, we can use:


ls -al ~/.ssh

To generate the new SSH keys we can use the below command in the terminal with the corresponding email id:


ssh-keygen -t rsa -C "paul.pronabananda@gmail.com"

It will prompt the filename where to save the key. We can forward with the default file. After that we need to provide the password, and confirm password for this key. The key will be generated. Now its the time of add the key with key-agent.

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Now its the time to make link between my pc and the github application. For this purpose, i will copy the content of the public key and save it in the ssh tab of the personal setting after loggin in to the gitub account. After completion, we need to test the connectivity through ssh.


ssh -T git@github.com

After providing password while prompted, it will give the message as:

Hi ! You've successfully authenticated, but GitHub does not provide shell access.

For details

Thursday, February 26, 2015

Git-Specific Commands

Some mostly used commands for Github. They all begin the same way, with the word “git.”
git init: Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.
git help: Forgot a command? Type this into the command line to bring up the 21 most common git commands. You can also be more specific and type “git help init” or another term to figure out how to use and configure a specific git command.
git status: Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.
git add: This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.
git commit: Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.”The -mindicates that the following section of the command should be read as a message.
git branch: Working with multiple collaborators and want to make changes on your own? This command will let you build a new branch, or timeline of commits, of changes and file additions that are completely your own. Your title goes after the command. If you wanted a new branch called “cats,” you’d type git branch cats
git checkout: Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check. You can use this command as git checkout masterto look at the master branch, or git checkout catsto look at another branch.
git merge: When you’re done working on a branch, you can merge your changes back to the master branch, which is visible to all collaborators. git merge catswould take all the changes you made to the “cats” branch and add them to the master.
git push: If you’re working on your local computer, and want your commits to be visible online on GitHub as well, you “push” the changes up to GitHub with this command.
git pull: If you’re working on your local computer and want the most up-to-date version of your repository to work with, you “pull” the changes down from GitHub with this command.

Pushing Up to Github Repo from Ubuntu [Linux]

To be a proficient programmer its mandatory to work with the projects of Github for development (both Project ans self) purpose. For windows, Github provide the application for easier access. But for Linux OS, we need to configure the Git at our pc. We will have to follow some steps for this purpose. We can check he following steps:

Installing Git for Linux

sudo apt-get install git

Configuring GitHub

 git config --global user.name "pronabananda"
 git config --global user.name "paul.pronabananda@gmail.com"

Creating a local repository

Local repository is which project folder we want to connect with the github project folder. For my case, i have created a folder named testproject. And through terminal i am now in the project folder.

Creating a repository on GitHub

Then i have created a repository in GitHub by click and typing. And after confirmation, i have ogt the code which will have be run in the already opened terminal.



- -Generated Code --
echo "# testproject" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/pronabananda/testproject.git
git push -u origin master
- -


Pushing Up local to Github repo:

Following the above code i have run the below code in my terminals to up my local repo. to Github repo:
--
echo "Its a intial testproject" >> README.md
git init
git add .        [ I have added all the files and folder. For this reason I have used . instead of any specific file name]
git commit -m "Initial commit"
git remote add origin https://github.com/pronabananda/testproject.git
git push -u origin master [For the case of first time, it will ask user id and password of Github Account]
--

For adding already existing repo:
git remote add origin https://github.com/pronabananda/testproject.git
git push -u origin master

--------------------------------------------------
If we want to omit some specific type of files and folder for pushing up to Github Repo from the local. For that case we will have to add a file named .gitignore containing the list of files and folder to be skipped. After pushing up the files, if we run the

git log  

it return the full id of the commit. In future for to download the specific state of the project we will have to use this.
----
root@PaulsofTech-WorkStation:/home/paul/workspace/testproject# git log
commit 8b59ac34c30d00a7c4975fadadf6fea52a98515c
Author: pronabananda
Date:   Thu Feb 26 00:51:15 2015 +0600

    Initial commit
---