git config --global user.name "Имя Фамилия"
git config --global user.email user@mail.comgit config --list --show-origingit filter-repo --mailmap my-mailmapCorrect Name <correct@email.com> <old@email.com> # Если хочешь внести изменения во внешний репозиторий, то просто клонируй его к себе
git clone https://github.com/github-name/test.git
# Войди в рабочий каталог
cd test
# Переключись в нужную ветку
git switch additional
# Измени файл и закоммить его
git add "index.html"
git commit -m "add new sections"
# Отправь на GitHub
git push git reset --soft HEAD^1 # откатываем локальную ветку, но не трогаем рабочую копию кода
git push --force origin HEAD # заменяем ветку во внешнем репозиторииgit revert HEAD # отменяем предыдущую правку
git push # отправляем во внешний репо
git revert --no-commit HEAD # отменяем отмену, но не коммитим сразу
# дальше оформляем уже правильный коммит, без ненужных файлов. git reset --soft master # начнём ветку заново от текущего мастера
# но все уже сделанные правки не пропадут, а останутся в индексе
git commit -m 'Это один коммит' # зафиксируем работу git reset $(git commit-tree HEAD^{tree} -m "Новое начало истории")git gc --prune=now --aggressivegit rm --cached package-lock.json
git commitgit clone старый_репо #скачать код
git reset $(git commit-tree HEAD^{tree} -m "Init") # очистить историю
git remote set-url origin новый_репо # подготовиться к отправке в новый внешний репо
git push -u origin main # отправить текущую ветку и связать ветки git fetchgit merge origin/stagegit rebase origin/stage git update-index --assume-unchanged <file>heroku create создаёт пустой репозиторий на хостинге Heroku и добавляет ссылку на него в локальный репозиторий. Но локального репозитория на тот момент ещё не было! В итоге remote с именем heroku теперь отсутствует и команда push не знает, куда отправлять бота.git remote add heroku https://git.heroku.com/cryptic-cliffs-15444.gitgit push -u heroku main #!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# Redirect output to stderr.
exec 1>&2
# полные пути от корня репо, разделенные символами новой строки
SECRET_FILES='secret.txt
dir/secret2.txt'
if git diff --cached --name-only $against |
grep --quiet --line-regexp --fixed-strings "$SECRET_FILES"
then
echo Попытка закоммитить запрещённые файлы
exit 1
else
exit 0
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --❯ git add secret.txt
❯ git commit -m 'test hook'
Попытка закоммитить запрещённые файлы