About Git

Git repository initialization:

git init

Create the file .gitignore for the list of files which shouldn't be kept track of. There is an example of the file .gitignore:


Add all existing files under version control:

git add .

Create the initial commit:

git commit

In the first line of a text editor to type the name of the commit, in the next line there is more detailed description of the commit:

Начальный коммит   

This is the first commit that contains the source files for the project
# Please enter the commit message for your changes. Lines starting 
# with '#' will be ignored, and an empty message aborts the commit. 
# On branch master 
# Initial commit 
# Changes to be committed: 
#   (use "git rm --cached ..." to unstage) 

For exit press «F2» and then «Y» and on request:


press «Enter»

Rewrite the current commit:

git commit --amend

The next commits are to be done with the key «-a» for automatic indexing of changes in files:

git commit -a

Viewing the current status of the git repository:

git status

After performing the commit the status will be similar to the following message:

git status
# On branch master 
nothing to commit (working directory clean) 

To view the commit history you can use the command:

git log --oneline 
8f5e4c4 Добавлен функционал при отображении графиков
9eac233 Исправлена ошибка с буфером
ec4bba1 Начальный коммит 

To view history you can use the graphical version

For switching to a specific commit:

git checkout 9eac233

Creating of a new branch:

1) git branch debugBranch

After running the command «git branch debugBranch» a new branch will be created, but to start working in it, you should switch to this branch using the command:

2) git checkout debugBranch
Switched to branch 'debugBranch'

To view the list of branches, use the command:

git branch
* debugBranch

For viewing the difference between the current repository and any commit the following command is to be run:

git diff ec4bba1

Sometimes there is a situation that the new commit doesn't belong to any of the branches.
This can be seen using the command:

git branch
* (no branch)

The next message is also about it:

Warning: you are leaving 1 commit behind, not connected to
any of your branches

For connecting commit to the last active branch is to run the following command:

git merge HEAD@{1}