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.
Check out our brand new course, Learn Git! Use #Git for version control. https://t.co/7S9y0QCKQp #code #coding pic.twitter.com/HS1RJaQ7vR
— Codecademy (@Codecademy) November 11, 2015
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.
The word init means initialize. The command creates a new Git repository.
A Git project can be thought of as having three parts:
- A Working Directory: where you’ll be doing all the work: creating, editing, deleting and organizing files
- A Staging Area: where you’ll list changes you make to the working directory
- A Repository: where Git permanently stores those changes as different versions of the project
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
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.
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
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
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
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.