New course by @Codecademy – Use #Git for version control.

Have I ever mentioned how much I love Codecacademy courses? I do. It’s a great and free way to study new programming languages in front of your computer. Few days ago they created new course with basics of GIT.

Ok, so let’s start #git course. You can find here basic git commands like: git init, git status, git add, git diff, git commit, git log.


Git is a software that allows you to keep track of changes made to a project over time. Git works by recording the changes you make to a project, storing those changes, then allowing you to reference them as needed.

Source


git init

The word init means initialize. The command creates a new Git repository.

Source


A Git project can be thought of as having three parts:

  1. A Working Directory: where you’ll be doing all the work: creating, editing, deleting and organizing files
  2. A Staging Area: where you’ll list changes you make to the working directory
  3. A Repository: where Git permanently stores those changes as different versions of the project

Source

git-projekt


git status

As you write the project, you will be changing the contents of the working directory. The command inspects the contents of the working directory and staging area

Source


git add filename

Add file you are editing (example.txt) to the staging area in Git. Recall that you will need to identify the file by its name. So the command adds files from the working directory to the staging area.

Source


git diff filename

you can check the differences between the working directory and the staging area with git diff so the command shows the difference between the working directory and the staging area

Source


git commit -m “Your message here”

A commit permanently stores file changes from the staging area in the repository

Standard Conventions for Commit Messages:

  • Must be in quotation marks
  • Written in the present tense
  • Should be brief (50 characters or less) when using -m

Source


git log

Commits are stored chronologically in the repository so command shows a list of all previous commits

In the output you’ll recive:

  • A 40-character code, called a SHA, that uniquely identifies the commit.
  • The commit author
  • The date and time of the commit
  • The commit message

Source

git-log


In next part of this course I’ll show you different ways to undo changes made to a Git project and when to use them.

Leave a Reply

Your email address will not be published. Required fields are marked *