How to create a repository and push on to Github with Git.

Abigail felix
Sep 5, 2018 · 3 min read

Firstly, Download the installer for Windows or the operating system you’re using from the Git official website: http://github.com.

Execute the downloaded file. In the page Select Components you can leave the options at their defaults.

Note: Git for Windows comes with it's own command prompt (Git Bash), that besides git commands it has some useful Unix commands (and it looks better than Windows default prompt).

On the next screen (Adjusting your path environment), I choose the most conservative option: Use Git Bash only. This will make git commands available only in Git Bash, and will not alter your PATH variable. Click Next.

After that one more Next, Finish and Git is installed.

NOW


Creating a local repository.

  1. Create a folder and name it.

2.Right click it and choose Git Bash Here.

Before anything else, let's inform Git who you are, so your commits can be identified. Enter the commands, replace the quoted data with your real name and e-mail: (press Enter after each one)

Processes to undergo when the git bash finally opens.

Input the following :

  1. git config --global user.name
  2. git config --global user.email that is "your_email@example.com"

To initialize a Git repository on this folder:

  1. Input git init .

Then

Add a new file and commit it. Look at the command sequence (press Enter after each one):

  • Input touch test.txt(name of the file).
  • Input git add . git commit -m "First commit"(type whatever you wish to commit like here I used First commit).

You can create a file inside your folder any way you like, not necessarily with the touch command). we commit the changes with a message.

Sharing your code on GitHub.

Initial setup

If you don't have a GitHub account yet, go to http://github.com and create one. It's free.

After you signup and login.

Add a SSH key so GitHub can link your account with this computer. That way it won’t have to ask for your password on every commit.

On Git Bash enter the command:

  • ssh-keygen -t rsa -C "your_email@example.com"
  • Use the same email you registered at GitHub.
  • The next option will be for password. Enter a password (this is NOT your GitHub password). When it asks for a confirmation, enter the password again. Now enter the command:
  • Sublime ~/.ssh/id_rsa.pub
  • To open on Sublime the file that was created.

On GitHub, go to Settings and then SSH and GPG Keys. Click New SSH key.

Enter a title to identify this computer and in the field Key paste all the contents of the file id_rsa.pub.

Let's check if everything is ok. On Git Bash enter:

ssh -T git@github.com

It will ask if you want to connect to a remote machine. Type yes and press Enter. Next it will ask for a password. Enter the password you used on the ssh-keygencommand.

If you see a message like:

Hi user! You’ve successfully authenticated, but GitHub does not provide shell access,then everything is correct.

Create a remote repository.

  • Input git remote add origin.that is: git@github.com:user/repo_name.git.
  • Note that user/repo_name must be entered the same way they appear in your repository URL, like:

https://github.com/user/repo_name

Now, to send your files to GitHub, enter:

  • git push origin master
  • Inform the password of the SSH key if it asks.
  • Reload the page of your repo on GitHub and you should see your commited files.

Thank you.

Abigail felix

Written by

go-getter

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade