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
$ 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
Выполнить слияние какой-либо ветки с текущей веткой
Добавить файлы, которые были изменены:
Add only the modified and deleted files (without untracked)
$ git add -u
Удалить файлы из отслеживаемых:
Создать коммит:
Добавить внешний репозиторий:
Залить последние изменения на внешний репозиторий:
$ git push -u origin master (след. раз можно git push для данной ветки)
$ git push
Слить последние изменения из репозитория для указанной ветки:
Отменить изменения для конкретного файла:
$ 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