Last active
June 30, 2022 07:15
-
-
Save j-tap/8af4bc06b3f8dcd7f88b814c15c4c41c 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
| # Отменить последний коммит, но сохранить изменения: | |
| $ git reset HEAD~ | |
| # Удалить последний коммит и откатить изменения: | |
| $ git reset --hard HEAD~ | |
| # Привязать к новому проекту существующий репозиторий | |
| git init | |
| git add . | |
| # если нужно изменить имя ветки (git branch -m main) | |
| git commit -a -m 'start' | |
| git remote add origin {REPO} | |
| git pull --rebase origin main | |
| git push origin main (-f если граф разделён и нужно накатить) | |
| # Если файл попал в индекс и нужно убрать его из индекса (-r рекурсивно): | |
| git rm --cached path/to/file -r | |
| # Если ошибка refusing to merge unrelated histories | |
| git merge --allow-unrelated-histories myfunnybrancy | |
| # Если две ветки раздельно (в начале, когда в созданный репо пуш) | |
| git pull --tags -r | |
| # Очистить удалённый репозиторий и залить туда новые файлы | |
| git checkout --orphan temp | |
| git add -A # Add all files and commit them | |
| git commit -am 'clean' | |
| git branch -D master # Deletes the master branch | |
| git branch -m master # Rename the current branch to master | |
| git push -f origin master # Force push master branch to github |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment