In this post, we will create our first git repo and also make our first commit. Before getting started, I'm making 2 assumptions,

  1. You've heard of git and it's abilities.
  2. You've got git installed on your machine.
mkdir directory

cd directory

git init

vim file.txt

git status

git add file.txt

git status

git commit -m "COMMIT MESSAGE"

git log  

Dubem, what the hell did you just do?
Yep; WTH did I just do.
FEAR NOT!!!, for I shall set your mind free.

  1. Create the directory - If starting from scratch, go ahead and create a new directory. But, if you already have a directory, skip this step.
  2. Change into the directory - Navigate/change into the folder that will be put under version control.
  3. Initialize git - At this point, we've got to create the git repo in the current directory. The command git init will go ahead and setup the repo. It will also create a new directory called .git. This is where all the git configuration and metadata for the repo is stored.
  4. Create a file - Since we've got the repo set up, all that is left is to start doing our stuff. Here, I'm creating a file called file.txt. Optionally, you can go ahead and enter some text in that file.
  5. Check git status - Now, we can go ahead and check on the status of our repo. This command ``, should show us that there's one(or more) untracked file(s). Typically, the name of the file should be in red text.
  6. Add file to stage - In other to add this file to the repos for tracking, we use the git add file1 file2 ... filen command. In git terminologies, we say that the file(s) has been staged for commit.
  7. Check status, again - This should show that the file(s) added in the previous steps is ready to be committed. Typically these file name(s) will be shown in green
  8. Commit change - With the file(s) staged and ready to be committed, the next logical step is to go ahead and do the commit. As a requirement, we also need to specify a commit message, this is useful for when looking at the logs for the repo.
  9. Print the log - After making all these commits, we might some(day/time) want to see a text summary of our commits. This is where this command comes in handy git log.
  10. Check status, once again - If we run this again, we should see that we've got nothing left to commit anymore.

Hope this intro was useful to you. In the subsequent posts, I'll show some more advanced use cases.