-
-
Save maxfil333/0db287ba8b36d8de6ec9ba609cf9a121 to your computer and use it in GitHub Desktop.
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
0. Вход | |
User/.git-credentials: записать одну строку | |
https://maxfil333:[email protected] | |
1. Восстановить до состояния последнего коммита | |
git reset --hard HEAD | |
git checkout HEAD -- .\config\styles.css (для одного файла) | |
2. Удалить файл из индекса | |
git reset / git reset <file> | |
3. Создание побочной ветки | |
git add . | |
git commit -m 'Сохранить текущие изменения' | |
git checkout -b <имя_новой_ветки> | |
git add . | |
git commit -m 'Первый коммит в новой ветке' | |
git push origin <имя_новой_ветки> | |
4. Слияние с основной веткой. | |
git add . | |
git commit -m 'Сохранить текущие изменения' | |
git checkout master | |
git pull origin master | |
git merge newfeature | |
git commit | |
git push origin master | |
5. Удаление побочной ветки | |
git branch -d newfeature | |
git push origin --delete newfeature | |
6. Вернуться к коммиту с3 и начать работать с него. | |
Но оставить все коммиты без изменений | |
git checkout -b new-branch c3 | |
git add . # не обязательно | |
git commit -m "Your commit message for c6" | |
git checkout main | |
git merge new-branch | |
7. Разрешение конфликтов | |
git checkout main | |
git merge new-branch | |
git status | |
<<<<<<< HEAD | |
Это текст из основной ветки. | |
======= | |
Это текст из новой ветки. | |
>>>>>>> new-branch | |
Это текст из основной ветки и новой ветки. | |
git add file.txt | |
git commit -m "Resolved merge conflicts" | |
git log --oneline | |
8. Если вы хотите переместить файл с помощью самой команды Git, вы можете использовать команду git mv, | |
которая автоматически обновляет индекс Git: | |
git mv старый_путь новый_путь | |
git commit -m "Переместил файл файл.txt в новую папку" | |
git push | |
9. | |
git stash | |
git stash pop | |
10. PR | |
переключиться на ветку PR | |
git fetch origin pull/<номер_PR>/head:pr_test | |
git checkout pr_test | |
10.1 Просмотр ветки pr в master без переключения на pr | |
git checkout master | |
git fetch origin pr_test | |
git checkout pr_test -- . | |
11. Удалить не смерженую локальную ветку | |
git branch -D pr_test | |
12. SSH | |
terminal: | |
ssh-keygen | |
cat id_rsa.pub | |
git remote -v | |
git remote set-url origin <ссылка_на_репозиторий_для_доступа_по_ssh> | |
git remote -v | |
git add commit push | |
13. Github Personal Access Token | |
Settings → Developer settings → Personal access tokens → fine-grained token | |
Generate new token | |
Repository access (Only select repositories) | |
Permissions → Repository permissions | |
Contents → Read-only (для git pull этого достаточно). Если нужен git push - Read and write. | |
git remote -v (https://github.com/maxfil333/BT_certificate_engine.git) | |
Чтобы не вводить PAT каждый раз, сохрани его в диспетчере учётных данных Git: | |
git config --global credential.helper store | |
git pull | |
Когда Git запросит: | |
Username: Введи maxfil333 (или твой GitHub-username). | |
Password: Вставь новый token, созданный выше. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment