Last active
June 24, 2024 21:18
-
-
Save StudioEtrange/0c72e98ca981e5013371cc80f4ad6460 to your computer and use it in GitHub Desktop.
Various git tips
-
Delete 4 last commits from git history, replace them with only one commit, and push this new history to git server
git reset --soft HEAD~4
-
Create only one commit with the changes of previous deleted commits
git add . git commit -m "one commit with content of 4 deleted commit"
-
Push this new history to git server
git push --force -u origin main
-
Create a new branch with the content of all changes of all commit of the git history
git branch new_branch $(echo "init message" | git commit-tree HEAD^{tree})
-
Push this new history to git server and replace the main branch
git push --force -u origin new_branch:main
-
Efface branche temporaire, et remplace l'historique de la branche principale avec le nouvelle historique compressé
git branch -d new_branch git fetch origin git reset --hard origin/main
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment