Merge branch 'dev' into vhs
This commit is contained in:
commit
65217b8673
@ -6,36 +6,40 @@ tags: [ "data" ]
|
|||||||
|
|
||||||
## New Machines
|
## New Machines
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git config --global user.email "$YOUR_EMAIL"
|
git config --global user.email "$YOUR_EMAIL"
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git config --global user.name "$YOUR_NAME"
|
git config --global user.name "$YOUR_NAME"
|
||||||
```
|
```
|
||||||
|
|
||||||
# New Git
|
# New Git
|
||||||
|
|
||||||
Start a git in directory `$DIR`:
|
Decide on algorithm:
|
||||||
|
|
||||||
```bash
|
- If you're scared of insecure hash-sums, go with `hash=sha256`.
|
||||||
mkdir $DIR && cd $DIR
|
- If you don't know what a hash sum is, go with `hash=sha1`.
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
## Init the Git
|
||||||
git init
|
|
||||||
|
Start a git in directory `${DIR}`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git init --object-format=${hash} ${DIR}
|
||||||
|
cd ${DIR}
|
||||||
```
|
```
|
||||||
|
|
||||||
Make a file explaining what the project does, and tell `git` to track it:
|
Make a file explaining what the project does, and tell `git` to track it:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
echo "I hereby solemnly swear never to commit a binary." > README.md
|
echo "I hereby solemnly swear never to commit a binary file." > README.md
|
||||||
git add README.md
|
git add README.md
|
||||||
```
|
```
|
||||||
|
|
||||||
Then make the initial commit, explaining the change you just made:
|
Then make the initial commit, explaining the change you just made:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git commit
|
git commit
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -43,17 +47,17 @@ git commit
|
|||||||
|
|
||||||
Once you make a change to some file, add it and make a commit explaining it.
|
Once you make a change to some file, add it and make a commit explaining it.
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git add $FILE
|
git add $FILE
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git commit -m"change $FILE"
|
git commit -m"change $FILE"
|
||||||
```
|
```
|
||||||
|
|
||||||
Check your history:
|
Check your history:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git log
|
git log
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -64,20 +68,20 @@ Give it the same name as the `$DIR` directory, above.
|
|||||||
|
|
||||||
Add this as a remote:
|
Add this as a remote:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
REMOTE=gitlab
|
REMOTE=gitlab
|
||||||
git remote add $REMOTE https://gitlab.com/$USERNAME/$DIR
|
git remote add $REMOTE https://gitlab.com/$USERNAME/$DIR
|
||||||
```
|
```
|
||||||
|
|
||||||
Tell git you're pushing the branch "master" to the remote repo "origin":
|
Tell git you're pushing the branch "master" to the remote repo "origin":
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git push -u master origin
|
git push -u master origin
|
||||||
```
|
```
|
||||||
|
|
||||||
If someone makes a change on the remote, pull it down with:
|
If someone makes a change on the remote, pull it down with:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git pull
|
git pull
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -86,31 +90,31 @@ git pull
|
|||||||
A branch is a full copy of the project to test additional ideas.
|
A branch is a full copy of the project to test additional ideas.
|
||||||
You can make a new branch called 'featurez' like this:
|
You can make a new branch called 'featurez' like this:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git branch $FEATURE_BRANCH
|
git branch $FEATURE_BRANCH
|
||||||
```
|
```
|
||||||
|
|
||||||
Have a look at all your branches:
|
Have a look at all your branches:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git branch
|
git branch
|
||||||
```
|
```
|
||||||
|
|
||||||
Switch to your new branch:
|
Switch to your new branch:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git checkout $FEATURE_BRANCH
|
git checkout $FEATURE_BRANCH
|
||||||
```
|
```
|
||||||
|
|
||||||
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
|
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git branch -D $FEATURE_BRANCH
|
git branch -D $FEATURE_BRANCH
|
||||||
```
|
```
|
||||||
|
|
||||||
Or if it's a good branch, push it to the remote:
|
Or if it's a good branch, push it to the remote:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
remote=origin
|
remote=origin
|
||||||
git push $remote $FEATURE_BRANCH
|
git push $remote $FEATURE_BRANCH
|
||||||
```
|
```
|
||||||
@ -119,13 +123,13 @@ git push $remote $FEATURE_BRANCH
|
|||||||
|
|
||||||
Once you like the feature, merge it into the main branch. Switch to master then merge it:
|
Once you like the feature, merge it into the main branch. Switch to master then merge it:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git merge $FEATURE_BRANCH
|
git merge $FEATURE_BRANCH
|
||||||
```
|
```
|
||||||
|
|
||||||
And delete the branch, as you've already merged it:
|
And delete the branch, as you've already merged it:
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git branch -d $FEATURE_BRANCH
|
git branch -d $FEATURE_BRANCH
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -133,7 +137,7 @@ git branch -d $FEATURE_BRANCH
|
|||||||
|
|
||||||
## Pulling another git repo into a subtree
|
## Pulling another git repo into a subtree
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git subtree add -P config git@gitlab.com:bindrpg/config.git master
|
git subtree add -P config git@gitlab.com:bindrpg/config.git master
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -141,27 +145,27 @@ git subtree add -P config git@gitlab.com:bindrpg/config.git master
|
|||||||
|
|
||||||
## Delete All History
|
## Delete All History
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git checkout --orphan temp
|
git checkout --orphan temp
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git add -A
|
git add -A
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git commit -am "release the commits!"
|
git commit -am "release the commits!"
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git branch -D master
|
git branch -D master
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git branch -m master
|
git branch -m master
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git push -f origin master
|
git push -f origin master
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -169,21 +173,21 @@ Gitlab requires more changes, such as going to `settings > repository` and switc
|
|||||||
|
|
||||||
## Clean up Bloated Repo
|
## Clean up Bloated Repo
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git fsck --full
|
git fsck --full
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git gc --prune=now --aggressive
|
git gc --prune=now --aggressive
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git repack
|
git repack
|
||||||
```
|
```
|
||||||
|
|
||||||
## Find Binary Blobs
|
## Find Binary Blobs
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
git rev-list --objects --all \
|
git rev-list --objects --all \
|
||||||
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
|
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
|
||||||
| sed -n 's/^blob //p' \
|
| sed -n 's/^blob //p' \
|
||||||
|
19
data/interactive_string_substitution.md
Normal file
19
data/interactive_string_substitution.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "Interactive String Substitution"
|
||||||
|
tags: [ "data", "vim", "substitution" ]
|
||||||
|
---
|
||||||
|
|
||||||
|
Want to find and replace, but also confirm each instance?
|
||||||
|
|
||||||
|
```sh
|
||||||
|
vim -c "%s/${pattern}/${replacement}/gc" -c 'wq' ${file}
|
||||||
|
```
|
||||||
|
|
||||||
|
Notice that double-quotes (`"`) in the first command (`-c`).
|
||||||
|
|
||||||
|
Alternatively, check with an example string:
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sed "s/${pattern}/ARGLEBARGLE/g" ${file} | grep 'ARGLEBARGLE'
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user