Created
July 10, 2019 14:04
-
-
Save nikonov91-dev/368e3fb95739221aa2939c6399848eac to your computer and use it in GitHub Desktop.
gist of git tips on russian. Полезные комманды git с описанием
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello git | |
commit - that snapshot | |
working directory | |
checkout - процесс когда файлы скопированы из репозитория в рабочую папку | |
staging area/index - файл-таблица содержащая список файлов загруженных в порядке по времени записи в репозиторий | |
poise - держать/висеть/ быть готовым к действию | |
SHA - ID номер коммитов состоящий из 40 символов /SHA - secure hash algorithm | |
branch - ответвление проекта от основного проекта без изменения второго. | |
consistency - непротиворечивость | |
topic branch - это ответвление коммитнутых и внесенных изменений и подтверждение их добалвлений в первоисточник проекта (в ситуации pull requesta) | |
squashing - слиянение коммитов в один коммит | |
git init - create brand new repos on pc | |
git clone - clone within pc | |
git merge origin/master --allow-unrelated-histories // чтобы слить удаленный и локальный реп | |
git status | |
git log - information about the existing commits | |
to scroll down, press | |
j or ↓ to move down one line at a time | |
d to move by half the page screen | |
f to move by a whole page screen | |
to scroll up, press | |
k or ↑ to move up one line at a time | |
u to move by half the page screen | |
b to move by a whole page screen | |
press q to quit out of the log (returns to the regular command prompt) | |
git log -—oneline - makes all commits be shown in one line | |
git log -—stat - makes all commits be shown fully detailed | |
git log —stat -p - may be used | |
git log -p -w - короче добавляя лишнюю строку старый сместившийся код не показывается удаленным и добавленным ниже | |
git log --oneline --decorate --graph --all | |
где —-decorate - help see commit’s tag | |
-—graph - показывает как разветвляется ветка для одного ответвления | |
—-all - показывает все ответвления из репозитория | |
git show - info about the given commit | |
git add файл.хтмл - добавить файл/ы в список коммитируемых | |
git add . - добавить в коммит все файлы | |
git add <file1> <file2> … <fileN> | |
git unstage файл.хтмл - вернуть файл после добавления в коммит | |
git branch -d branchName - удалить ветку | |
git commit | |
git giff index.html - difference between before and after commit of one file | |
добавить в .gitignore файл чтобы не коммитить | |
set up sublime text 3 as git editor: | |
git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n -w" | |
******************************************************* | |
Globbing lets you use special characters to match patterns/characters. In the .gitignore file, you can use the following: | |
blank lines can be used for spacing | |
# - marks line as a comment | |
* - matches 0 or more characters | |
? - matches 1 character | |
[abc] - matches a, b, or c | |
** - matches nested directories - a/**/z matches | |
a/z | |
a/b/z | |
a/b/c/z | |
So if all of the 50 images are JPEG images in the "samples" folder, we could add the following line to .gitignore to have Git ignore all 50 images. | |
git tag -(action) tag_name SHA | |
actions: | |
-a - annotation tag | |
-d - delete tag | |
git checkout -b branchName - одновременно создает и переключается на ответвление | |
git checkout -b branchName commitNameBase - основа для нового ответвления | |
возврат изменений | |
git commit —-amend - вносить изменения в самый последний коммит (если забыл вложить файл в коммит или сделал ошибку в названии коммита)(so you'd make changes to the necessary CSS and/or HTML files to get the forgotten link styled correctly, then you'd save all of the files that were modified, then you'd use git add to stage all of the modified files (just as if you were going to make a new commit!), but then you'd run git commit --amend to update the most-recent commit instead of creating a new one.) | |
git revert - возвращает изменения к коммиту с shaXXXXXX | |
git reset —-hard | |
ОТНОСИТЕЛЬНЫЕ КОММИТНЫЕ СЫЛКИ | |
^ - предыдущий родительский коммит | |
~ - первый родительский коммит | |
the parent commit – the following indicate the parent commit of the current commit | |
HEAD^ | |
HEAD~ | |
HEAD~1 | |
the grandparent commit – the following indicate the grandparent commit of the current commit | |
HEAD^^ | |
HEAD~2 | |
the great-grandparent commit – the following indicate the great-grandparent commit of the current commit | |
HEAD^^^ | |
HEAD~3 | |
git reset -—mixed | |
—-soft | |
—-hard | |
reset - помогает перенести хэд коммитов, удалить коммиты, вернуть коммитнутые изменения до адднутого состояния | |
git branch backup - создание резервной копии | |
git remote - manage remote repos | |
git remote add origin https://…/….git - создание удаленного с локальным репом | |
git push - send changes to the remote | |
git push origin master - отправить в удаленный репозиторий | |
git push origin master -f - переписать силой удаленный репп —-force | |
чтобы запушить со своей ветки нужно git push -u origin feature_branch_name | |
а потом задать request на merge | |
git pull - retrieve updates from the remote | |
git fetch - позволяет загрузить коммиты с удаленного репа не сливая с мастером, после необходимо слитие (merge) с мастером | |
git remote -v - посмотреть адрес удаленного репа | |
git shortlog -s -n - позволяет увидеть количество коммитов проекта | |
где -s - to show just the number of commits | |
-n - sort them numerically | |
git log --author=Surma - фильтровать по автору | |
git log --grep=bug or git log --grep bug - найти все коммиты включающее слово Баг | |
git remote add sourseRepoName https://…/….git - позволяет добавить слежение за исходным мастер-ответвлением и загружать последние изменения в локальный репо | |
git rebase - команда для объединения комммитов | |
git rebase -i HEAD~3 - объеденить 3 последних коммита в один ( подсчет идет с Хеда и не включает его, типа объединить все коммиты начиная от Хед~0 и заканчивая 2м доходя до 3го но не включая его) | |
git rebase master - если нужно объединить мастер с моими изменениями после отпочкования от мастера | |
git fsck --lost-found - посмотреть коммиты из мусорки (к прим. после хард ресета), дальше нужно git merge провести | |
git cherry-pick --ff 43a7a2d (чтобы применить нужно быть в нужной ветке) | |
еще одна путевая статься как вернуть при удалении https://medium.com/@CarrieGuss/how-to-recover-from-a-git-hard-reset-b830b5e3f60c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment