Git CLI hints: Difference between revisions
From WikiMLT
m (Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:DevOps and SRE) |
m (→References) |
||
Line 31: | Line 31: | ||
== References == | == References == | ||
* [https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa | * Stack Overflow: [https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa How to delete all commit history in GitHub?] | ||
* [https://stackoverflow.com/q/5613345/6543935 | * Stack Overflow: [https://stackoverflow.com/q/5613345/6543935 How to shrink the .git folder] | ||
*[https://stackoverflow.com/a/32833411/6543935 | * Stack Overflow: [https://stackoverflow.com/a/32833411/6543935 How to clone all repos at once from GitHub?] | ||
<noinclude> | <noinclude> | ||
<div id='devStage'> | <div id='devStage'> |
Revision as of 15:21, 15 September 2022
Append a file to a branch
touch file.name
git add -A
git commit -am "my update msg"
git push
How to shrink the .git folder
git gc --aggressive --prune # will perform garbage collection in your repository and prune old objects.
git repack -a -d --depth=250 --window=250 # It's better to use this command, because 'git gc --aggressive' is considered to be bad practice.
Delete all commit history
git checkout --orphan latest_branch # Checkout
git add -A # Add all the files to the 'current' branch
git commit -am "commit message" # Commit the changes
git branch -D main # Delete the branch 'main'
git branch -m main # Rename/move the 'current' branch to main
git push -f origin main # Finally, force update your repository
Delete/Remove a branch
git branch -d <branch-name>
References
- Stack Overflow: How to delete all commit history in GitHub?
- Stack Overflow: How to shrink the .git folder
- Stack Overflow: How to clone all repos at once from GitHub?