mirror of
https://github.com/cupcakearmy/memoir.git
synced 2025-09-10 01:40:39 +00:00
update to nextra 4
This commit is contained in:
17
content/git/clean.md
Normal file
17
content/git/clean.md
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
tags:
|
||||
- git
|
||||
- clean
|
||||
- gitignore
|
||||
- delete
|
||||
---
|
||||
|
||||
# Delete all files mentioned by `.gitignore`
|
||||
|
||||
This command is useful if you want to reset a repository to it's checked out state.
|
||||
|
||||
```bash
|
||||
git clean -Xdf
|
||||
```
|
||||
|
||||
[Original SO Link](https://unix.stackexchange.com/a/542735)
|
28
content/git/clear-history.md
Normal file
28
content/git/clear-history.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Clear history
|
||||
|
||||
This removes all commits from the past.
|
||||
|
||||
```bash
|
||||
# Checkout
|
||||
git checkout --orphan latest_branch
|
||||
|
||||
# Add all the files
|
||||
git add -A
|
||||
|
||||
# Commit the changes
|
||||
git commit -am "commit message"
|
||||
|
||||
# Delete the branch
|
||||
git branch -D main
|
||||
|
||||
# Rename the current branch to main
|
||||
git branch -m main
|
||||
|
||||
# Finally, force update your repository
|
||||
git push -f origin main
|
||||
|
||||
# Optionally clear local caches
|
||||
git gc --aggressive --prune=all
|
||||
```
|
||||
|
||||
https://stackoverflow.com/a/26000395
|
11
content/git/remove-from-remote.md
Normal file
11
content/git/remove-from-remote.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Remove files from repository
|
||||
|
||||
How to remove files from the repository, without deleting them locally. [Original SO](https://stackoverflow.com/a/1143800)
|
||||
|
||||
```bash
|
||||
# File
|
||||
git rm --cached file_to_remove.txt
|
||||
|
||||
# Dir
|
||||
git rm --cached -r directory_to_remove
|
||||
```
|
20
content/git/remove-merged-branch.md
Normal file
20
content/git/remove-merged-branch.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
tags:
|
||||
- git
|
||||
- branch
|
||||
- clean
|
||||
- delete
|
||||
---
|
||||
|
||||
# Delete all local branches that are already merged.
|
||||
|
||||
This command is useful if you have a buch of local branches that you don't need anymore.
|
||||
|
||||
```bash
|
||||
git branch --merged | grep -v \* | xargs git branch -D
|
||||
```
|
||||
|
||||
[Original SO Link](https://stackoverflow.com/a/10610669)
|
||||
|
||||
|
||||
|
9
content/git/remove-secrets.md
Normal file
9
content/git/remove-secrets.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Remove secrets after being pushed
|
||||
|
||||
If you accidentally pushed a secret or some file that should not be publicly available in your git repo, there are a few ways. My personal fav is [BFG](https://rtyley.github.io/bfg-repo-cleaner/).
|
||||
|
||||
> `--no-blob-protection` also modifies you latest commit, by default that is turned off.
|
||||
|
||||
```bash
|
||||
bfg -D "*.txt" --no-blob-protection
|
||||
```
|
11
content/git/reset-files.md
Normal file
11
content/git/reset-files.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Reset Files
|
||||
|
||||
How to reset files from another branch.
|
||||
|
||||
```sh
|
||||
# New way
|
||||
git restore my/file.md
|
||||
|
||||
# Old way
|
||||
git checkout origin/HEAD -- my/file.md
|
||||
```
|
16
content/git/revert-commit.md
Normal file
16
content/git/revert-commit.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Revert branch to commit
|
||||
|
||||
Revert a branch to a certain commit, discarding newer ones.
|
||||
|
||||
```bash
|
||||
# Specific commit
|
||||
git reset --hard a1d6424
|
||||
|
||||
# Commits back
|
||||
git reset --hard HEAD@{3}
|
||||
```
|
||||
|
||||
```bash
|
||||
# Push
|
||||
git push -f
|
||||
```
|
Reference in New Issue
Block a user