General

How to access github remotly from local using ssh. by ON April 22 2019

This post may help the users who are new at git and want to set-up the github and configured local with remote using ssh key.

1.Install git in your local machine:-:

sudo apt-get install git

To setup in any system go to link

2.Configure git with your user details.

git config --global user.name "your username here"
git config --global user.password "your password here"  
git config --global user.email "your email id here"

3.Check username and password:-

git config --global user.name
git config --global user.password 
git config --global user.email 

4.Now configured your local system with remote using ssh

  1. Generate the SSH key with a command ( see here ):-
    ssh-keygen -t rsa -b 4096
  2. Above command will generate some file.
    • Copy the content fromid_rsa.pub the generated file which is public SSH key.
    • Paste the content into your GitHub/BitBucket account on the SSH key section:-
      1. Go to your GitHub account and login:- click here
      2. Click on settings
      3. Select an optionSSH and GPG key
      4. Generate New ssh key
      5. Give title any (which you prefer)
      6. Paste public key which is generated in a file id_rsa.pub

5.Now you can create or clone repo.

Get repo by cloning just:-

 git clone [email protected]:YOUR_USERNAME/REPO_NAME.git 

For new repo go to your account and create new one like hello_world.

echo "# Hello_World" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:username_here/Hello_World.git
git push -u origin master

Note:-

1. Check correct remote before pushing any changes on git:-

git remote -v orgit config --get remote.origin.url

2. Always create a new branch for any New/Change/Feature/Fix.

3. Always check the status after change a file.

git status

4. Check the difference in file

git diff [filename]

5. Add file/folder one by one so don’t use git add . ( all )

so use git add file_name/folder_name

6. After adding a file commit your changes

git commit -m "Your message for the commit"

7. Then push the changes

git push origin branch_name

If you have any question regarding above steps please comment or if need any changes in existing steps then also.

Thank you :>)

author's avatar ALL POST
Knowledge contribution is better than any contribution.

RELATED POST


1. Welcome to Best learner

BY March 17 2019
LEAVE A COMMENT

Leave a Reply

Your e-mail address will not be published. Required fields are marked *