Creating and pushing your first commit in GitHub

Creating and pushing your first commit in GitHub

Create a new repository on GitHub

  • Click on the new repository button

  • Please give it a title and a good description, and click the Create Repository button.

  • Copy repository information

  • Open your terminal and go to the folder where you want to save your repository

  • Run git clone repository-information in my case git clone [git@github.com](<mailto:git@github.com>):essau-net/my-first-commit.git. This command will clone your remote repository into your local

  • Enter into your repository folder and open your editor preference

  • Create a README.md file and add the following text
# My first commit
This is an example of my first commit
  • go back to your terminal and run git status. This will give information about your files. Usually, files with red color are in a modified state, and files with green color are in a stage state. It should look like this:

  • Run git add README.md and if you run git status It should look like this:

  • Now let's commit with git commit -m "My first commit" git commit id used to create a commit and the option -m is used to tell git you want to add a comment to your commit (you should always add a comment to your commits).

  • Now run git push origin main to add your changes to your remote repository.

    1. origin is how git identifies your remote repository. You usually have to configure this, but since you clone a remote repository, git configure it for you

    2. main is the name of the branch where you want to update your info

And that's it now. You just created your first commit and published it into a remote repository. Congratulations 🥳