Feb 13, 2017

Git

Configuration

Setup name and email

$ git config --global user.name "Ivan Ivanov"
$ git config --global user.email ivanov@example.com

Show current settings

$ git config --list

Disable cert verify (permanently)

$ git config --global http.sslVerify false

Generate key

# RSA (Rivest–Shamir–Adleman)

$ ssh-keygen -b 2048 -t rsa

EdDSA (Edwards-curve Digital Signature Algorithm)

$ ssh-keygen -t ed25519 -C "rokshd@example.org"

Copy key pair to ~/.ssh/

Add key to Git Bash (windows)

Add path to key to config C:\Program Files\Git\etc\ssh\ssh_config

    IdentityFile ~/.ssh/your-ssh-private-key

Basic workflow

Create local repo

$ git init

Download source code from remote repository

$ git clone https://path/to/the/repository.git

Push to remote repositiry

$ git remote add origin git@github.com:path/to/the/repository.git
$ git push -u origin master


Disable cert verify (temporary)

$ git -c http.sslVerify=false clone https://path/to/the/repository.git

Show current branch name

$ git branch

Show names for all branches 

$ git branch -a

Switch to the specific branch

$ git checkout test-branch

Create new branch and switch to it

$ git checkout -b new-branch

Show all commits for the current branch

$ git log
$ git log --graph

Move to the specific commit in the current branch

$ git reset --hard f9de5034ed4f6c1174137d06c85bad637c5c5890

Remove the specific branch

$ git branch -d test_branch

Выполнить слияние какой-либо ветки с текущей веткой

$ git merge master

Просмотр изменений по отношению к последнему коммиту:

$ git status

Добавить файлы, которые были изменены:

$ git add .

Add only the modified and deleted files (without untracked)

$ git add -u

Удалить файлы из отслеживаемых:

$ git rm -r --cached .idea/misc.xml

Создать коммит:

$ git commit -m "Commit description"

Добавить внешний репозиторий:

$ git remote add origin https://github.com/rokshd/test_app

Залить последние изменения на внешний репозиторий:

$ git push origin master
$ git push -u origin master (след. раз можно git push для данной ветки)
$ git push

Слить последние изменения из репозитория для указанной ветки:

$ git pull origin test-branch
$ git pull

Отменить изменения для конкретного файла:

$ git checkout db/migrate/20170224101945_create_answers.rb

$ git stash list

$ git stash apply

$ git pull

To unstage a specific file

$ git reset <file>

REBASE

After committing changes to your branch, checkout master and pull it to get its latest changes from the repo

$ git checkout master
$ git pull origin master

Then checkout your branch and rebase your changes on master

$ git checkout RB
$ git rebase master... 

or last two commands in one line:

$ git rebase master RB

Kubernetes

kubectl installation $ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl...