For uploading the code in Git, we need to setup SSH key in GIT
RSA key is a public and private key.
The Private key will be on your computer and you will add the public key to GitHub.
So once this done Github will trust your computer to upload the code.
We share public key with GitHub and private key in Desktop.
In git bash enter following command
ssh-keygen -t rsa -C "youremailid@gmail.com"
This will create .ssh folder in C:\Users\machine_name\.ssh
After your .ssh folder creation
Go to GitBash
type-> ssh -T git@github.com (this will test keys are properly setup)
Now to Add project in the Git Repo
Go to git Bash
Go to your project location
Type-> git init (It will add .git folder)
Type-> git add . (this will add all the folders into staging area)
Type-> git status
Type-> Git commit -m "first commit"
Type-> git log (to see the status of commit)
Note: Till now code has not been pushed to git hub and all the things are in local machine
To add repository in Git
We use "remote add"
origin tells where the origin is
git remote add origin
Go to Git Hub account in your browser and then go to your repository and Click on SSH link
Not in Git Bash Enter the following command
git remote add origin git@github.com:neerajabc/myjd.git (Now git knows your origin)
Now we will upload the code in Git Hub using Push
git push origin master (We are telling github to push our master branch to origin)
It will ask you for the passphrase (the same you setup when you created RSA Key)
Enter passphrase for key '/c/Users/lakshay/.ssh/id_rsa':
Now your code will be visible in your Repository (Refer Below Screen)
No comments:
Post a Comment