Getting The Best Out of GitHub (Part 2)

Here is the second article in the series on how you can get the best out of GitHub. As you know, Github is the social media for programmers. The first article already outlines the meaning of git, github and the preliminary details. We now expatiate on all these. Here we go!

Add a new file to the repository

By running on the touch command or using any text editor of your choice, you can go ahead with adding a new file to the project.

Once you have done this successfully, the changes made inside the repository will be noticed by Git. However, Git will not keep track of the file officially except you have instructed it to do so.

After you have created the new file, make use of the git status command to check the files that Git knows are in existence. As you do this, you will get the following message; “Hey, we noticed that you just created a new file called cfrank.txt, but until you use the ‘git add’ command, we are not going to do anything with it”.

Moving Forward: Important terminologies you need to know

Before we continue, there are some important terminologies which are expedient and absolutely necessary for you to know.

Commit: This is a record of the files that you have changed since the previous time you made a commit. Basically, you make changes to your repository (for example, modifying or adding a file) and thereafter tell Git to place those files into a commit.

Before you add any file to the commit, you have to add it to the staging environment first. To do this, you may use the git add <filename> command. Once you have added all the files you want in the staging environment, you can inform Git to package all of them into a coming by using the git commit command.

Adding a file to the staging environment

To add a file to the staging environment, you will use the git add command. 

Once you do this and you run the git status command, you will confirm that the Git has added a file to the index or staging environment.  

 Remember that file has not been added to the commit yet, it is about to. 

Creating commits

You can now make your first commit. As usual, you are to do your work in the directory. If you create new folders and/or files, they will not be tracked by Git unless you instruct it to do so

git add newFile1 newFolder1 newFolder2 newFile2

Committing makes a “snapshot” of every single thing that is being tracked into your repository

  • You are required to input a message telling what you have done.

git commit –m “Uncrevulated the conundrum bar”

git commit

  • Then the version will open an editor so that you can put in the message
  • To finish this, just save and quit the editor
  • The format of the commit message is more like this:
  • One line that contains a complete summary
  • However, If it is more than one line, then, the second line must be blank

The message that will be at this commit should be related to what the commit encompasses – maybe it’s just fixing a typo or maybe it’s a bug fix or maybe it’s a new feature. Don’t put a message like “foobar” or “asdfadsf”. That will make the other persons who see your commit sad. As in, extremely sad.

GD Star Rating
loading...
GD Star Rating
loading...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.