Skip to content

EnhancedProtection/Github-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Github CLI!

How To Use Git CLI

For Termux

pkg update && pkg install openssh git gh -y

For Linux

sudo apt update && sudo apt install ssh git gh -y

Configure your username with this command

git config --global user.name "username"

Now configure your email with this command

git config --global user.email "email@emaple.com"

Note :

  • The username and email must match to your github account
  • The username may be case sensitive

Now create a directory to store ssh key

mkdir -p ~/.ssh

Create ssh key using this command

ssh-keygen -t rsa -b 2048 -C "email@example.com" -f ~/.ssh/id_rsa

You will be asked for some info fill them according to your choice or just press enter and enter again until it finishes.

Configure github account with cli

As we have created the ssh-key now its time to add that key into our github account by which we can authenticate to account by using CLI.

To do this the first steps is that we need to copy the public key of ssh for that we will be using a command

cat ~/.ssh/id_rsa.pub

Now copy the text (key) shown on the to the clipboard and follow the next steps

  1. Go to browser and log in to your github account
  2. Click on Setting
  3. Click on SSH and GPG Keys
  4. Click on "New SSH key"
  5. Now paste the ssh key in the "key" section you can choose a title whatever you want and the Key type must be set to "Authentication Key" Now click on "Add SSH key"

Configure gh cli to access & use git properly

gh auth login
Now it prompt to chosse account like this

choose github.com

Now choose HTTPS

Login with a web browser

Now you will see a code on your screen and a promt to open browser
Select the browser in which you are logged in with that account

Type the code shown on the terminal and click continue

In this screen you will see something like this just click "Authorize Github"

And at last you will see a screen like this

Congratulation you have configured your git & gh cli!

Now its time to upload a project to you github repo

move to your directory where you have stored your project and follow the steps

First we will initialize that directory

git init

Now add all the files and folders to git

git add .

Then we have to commit

git commit -m "Initial commit"

We can configure our branch, by default it is master branch

You can check branch by typing this command

git branch

To rename the branch to main type

git branch -M main

After all this we have to add the github repo

git remote add origin https://github.com/username/repo.git

The final step is to push the local git to github repo

git push -u origin main

Congratulations you have uploaded your first repo with cli

Now if you have changed anything to your file and you want to update it on the repo for that we don't have to do these all thinkgs this was for the first time.

Suppose we have changed any file now follow the steps.


Fist of all the add the current file to git

git add .

Then we need to commit it with a reason!

git commit -m "Updated README.md"

The final step is to push

git push

That's it you have updated your code to github repo

About

How to use Github with cli in Termux/Linux?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages