First Git Commit in GitHub

Github

Git is very important tool for all kinds of software development and source code management. To make your first git commit in GitHub actually not that hard.

Create A New Repository

√ Visit https://github.com and signup for a new account. If you already have one, please sign in.

√ Create a new repository by clicking this link https://github.com/new

First Commit in GitHub

Don’t forget to click the “Create repository” button.

Install git on your computer 

√ For Windows user click here https://git-scm.com/download/win. After download please install the Git.exe. Make sure Git Bash also gets installed. 

First Commit in GitHub

√ For Ubuntu user run this command on your terminal. 

sudo apt-get install git

√ For Mac user run this Homebrew command your terminal

brew install git

Create an SSH Key and Add in your GitHub

On Windows open git bash and run command 

ssh-keygen -t rsa -C "[email protected]"

On Linux or Mac run terminal and run command 

ssh-keygen -t rsa -C "[email protected]"

Give a new file path when it says “Enter file in which to save the key”.  The press enter.

It will create two keys in your .ssh directory one is private which has no extension and one is public which .pub extension. Now open .pub key in any text editor and select all and copy the content in your clipboard. 

Go here https://github.com/settings/keys and click the button on the top-right New SSH Key.

First Commit in GitHub

Now paste your the content you copied from .pub file and paste in the key. Also give a nice title.

First Commit in GitHub

Finally click the button Add SSH Key to finish the process.

Clone Your Empty Repository

Now open your repository page and copy the repository url, make sure you select SSH.

First Commit in GitHub

Now open your terminal and run command

git clone git@your_git_url

in my case it is 

git clone [email protected]:sminrana/MyFirstRepoOne.git

Now create a txt file in the MyFirstRepoOne directory and add any text. 

Run this command to know your git status

git status

Mine looks like this, my txt file name is any.txt. 

Add this txt file in git by running this command

git add any.txt

Then run git commit command

git commit  -m "My first git commit message"

Finally push your changes to the GitHub server

git push origin master

You can download this article as PDF

Download as PDF

Spread the love

Comments

Leave a Reply