by Daniil Suleiman

Git - это бесплатная распределенная система контроля версий с открытым исходным кодом, предназначенная для быстрой и эффективной работы с небольшими и очень крупными проектами. Он служит для отслеживания изменений в файлах и координации работы над этими файлами среди множества людей.

Git creator

Creator, and historically, the principal developer of the Linux kernel

"I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'."

(git means unpleasant person in British English slang)

Git alternatives

Git != GitHub

GitHub is a web-based hosting service for version control using Git

Clone a GitHub repository

$ git clone <your_repo_uri>

Generate ssh-key

$ cd ~/.ssh
$ ls
  id_rsa    id_rsa.pub

Check:

$ ssh-keygen

Generate:

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkD...

Show pub key:

Set ssh-key

Set config

$ git config --global --list
  user.name=Anton Bely
  user.email=anton.bely@iii.com

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

Global config:

origin and ...

$ git remote
  origin
$ git remote -v
  origin  git@bitbucket.org:randiii/conv-ui-patrons.git (fetch)
  origin  git@bitbucket.org:randiii/conv-ui-patrons.git (push)
$ git remote get-url origin
  git@bitbucket.org:randiii/conv-ui-patrons.git

Remote list:

Git flow example

Create an empty Git repository or reinitialize an existing one

Clone a repository into a new directory

Display help information about Git

Start a working area:

git commit

Record changes to the repository

git status

Show the working tree status

git add

Add file contents to the index

Work on the current change:

git checkout

Switch branches or restore working tree files

git merge

Join two or more development histories together

git branch

List, create, or delete branches

Branching and Merging:

git pull

Fetch from and integrate with another repository or a local branch

git push

Update remote refs along with associated objects

git fetch

Download objects and refs from another repository

Sharing and Updating Projects​:

Specifies intentionally untracked files to ignore

Create useful .gitignore files for your project

Homework:

Command Meaning
git clone git@github.com:r/r.git Get a copy of the central storage facility (the repository)
git branch first-task Create a local branch called "first-task"
git checkout first-task Swith to the first-task branch
git checkout -b first-task Create and switсh to the first-task branch
git add index.js Add index.js contents to the index.
git add . Add all content from the current folder to the index
git commit index.js Add index.js contents to the index
git push origin first-task Push the current state of your first-task branch, including all commits, up to github.
git pull Bring your local branch up-to-date with the state of the remote branch on github.

Git cheatsheet

Git allows a developer to copy a remote subversion repository to a local instance on their workstation, do all their work and commits in that local repository, then push the state of that repository back to a central facility (github).

git

By Daniel Suleiman