git config --global user.name "John Doe"
git config --global user.email "john.doe@example.com"
git config --global credential.helper 'cache --timeout 43200'
git config --global credential.helper 'store --file ~/.git-credentials'
git config --global --unset credential.helper
git config --global alias.rename 'branch -m'
git config --global core.editor "vim"
git reset --hard
git reset --hard HEAD^
git reset --soft HEAD~n
Pour annuler les modifications, remplacer soft par hard.
Puis pour posser la suppression sur le dépôt distant :
git push origin +HEAD
Depuis un dépôt “bare”, remplacer –hard par –soft.
git checkout c5f567 -- file1/to/restore file2/to/restore
Pour restaurer les fichier avant le commit (ici 1 commit avant) :
git checkout c5f567~1 -- file1/to/restore file2/to/restore
git rebase -i a7cc4794a8802708b2eaa75debb40c993f0fa958
L'ID est celui du commit qui précède le dernier membre de la fusion
OU
git rebase -i --root main
git rebase --root -i
Puis remplacer toutes les occurrences de pick par squash sauf la première.
Sous vim, il est possible de faire :
:%s/pick/squash/g
git commit --amend -m "Nouveau commentaire"
git commit --amend --author="Benjamin Féron <50001976+benjamin-feron@users.noreply.github.com>"
git filter-branch -f --env-filter '
WRONG_EMAIL="wrong@email.com"
NEW_NAME="New Name"
NEW_EMAIL="new@email.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
git branch -m <newname>
git branch -m <newname> <newname>
git push --delete origin v2.0
git push -u origin feature_branch_name
git push --all origin
git pull --rebase origin master
git tag -d <tagname>
git push --delete origin <tagname>
git tag | xargs git tag -d
git shortlog -nse
git shortlog -ns