Skip to content

Instantly share code, notes, and snippets.

@nezl
Last active December 27, 2025 12:46
Show Gist options
  • Select an option

  • Save nezl/e06c98903d61968a1291 to your computer and use it in GitHub Desktop.

Select an option

Save nezl/e06c98903d61968a1291 to your computer and use it in GitHub Desktop.
configure git for github
  1. cd into the directory
  2. go to https://github.com/new and create a new repo. DO NOT check the initialize repo with README option.
  3. you will get a screen like
  4. run git init to create an empty git repo. (it is empty because we need to add files to the git repo, it doesnt account for the files in the same folder automatically)
  5. run git add --all to add all files & folders in the current folder to git repo. run git status to see files added to git staging area
  6. run git commit -m "short message about what changes happen in this commit" : note that a message is required by git.
  7. add a remote (github repo) to your local git repo using command git remote add origin git@github.com:user/repo.git
  8. send your local git repo to github using git push -u origin master: here origin is set to github by the prev command. master is the default branch.
  9. open github.com/user/repo in browser to view the git repo on github. bahut likh diye. aage baad me

create a public-private key pair to authenticate with github over ssh. run ssh-keygen -t rsa -C "yourmail@mail.com"

======================================

After entering your public key in github

(you can skip this step) see if you have ssh private key added to your current configuration using ssh-add -l if the output is same as the one on github, youre good to go

verify your ssh access using the command : ssh git@github.com

if the output is on the lines of "hi priya...we do not provide shell access", youre good to go. notice that in github ssh settings page, the concerned ssh key has a green dot checked against it, thus verifying your access to github over ssh.

now we configure settings for your local git:

  • git config --global user.name "Your Name" : attaches your name to all commits which happen on your desktop
  • git config --global user.email "you@mail.com" : attaches your email to all commits which happen on your desktop
  • git config --global core.editor nano : set commit editor to nano, the easiest command line text editor. use ctrl+X to save and exit
  • git config --global color.ui true : enable colors in git command line wherever applicable

NOTE: github provides two kinds of access: one over https using username & password authentication & another over ssh using public-private key pair for authentication

@freddavis980
Copy link

freddavis980 commented Apr 27, 2025

This article on adding a git repo to an existing folder is super helpful! I once struggled with this myself. It's great how it breaks down each step clearly. try the tridle game

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment