Compare commits

..

No commits in common. "92d14e41b5b6bb0aa6de7afdf86286c1db6cd223" and "31f12e2161f52cab4e4c206de35a2c8f043c5112" have entirely different histories.

3 changed files with 35 additions and 51 deletions

View File

@ -92,7 +92,7 @@ A branch is a full copy of the project to test additional ideas.
You can make a new branch called 'featurez' like this:
```bash
git branch $FEATURE_BRANCH
git branch *featurez*
```
Have a look at all your branches:
@ -104,20 +104,19 @@ git branch
Switch to your new branch:
```bash
git checkout $FEATURE_BRANCH
git checkout *featurez*
```
And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":
```bash
git branch -D $FEATURE_BRANCH
git branch -D *featurez*
```
Or if it's a good branch, push it to the remote:
```bash
remote=origin
git push $remote $FEATURE_BRANCH
git push *origin* *featurez*
```
## Merging
@ -125,13 +124,13 @@ git push $remote $FEATURE_BRANCH
Once you like the feature, merge it into the main branch. Switch to master then merge it:
```bash
git merge $FEATURE_BRANCH
git merge *featurez*
```
And delete the branch, as you've already merged it:
and delete `featurez` as you've already merged it:
```bash
git branch -d $FEATURE_BRANCH
git branch -d featurez
```
# Subtree
@ -142,6 +141,34 @@ git branch -d $FEATURE_BRANCH
git subtree add -P config git@gitlab.com:bindrpg/config.git master
```
## Pulling a Subtree from an existing git
The project has subdirectories sub-1,sub-2,sub-3. The first should be its own repository, but should also retain its own history.
First, we extract its history as an independent item, and make that into a seprate branch.
```bash
git subtree split --prefix=sub-1 -b sub
```
If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3
Then go and create a new git somewhere else:
```bash
cd ..;mkdir sub-1;cd sub-1;git init --bare
```
Then go back to your initial git repo, and do the following:
git push ../subtest sub:master
Finally, you can clone this repo from your original.
```bash
git clone ../subtest
```
# Tricks
## Delete All History

View File

@ -1,9 +0,0 @@
---
title: "git secret"
tags: [ "data", "git" ]
---
This utility is largely useless, as it can only identify people by their email.
So if someone has multiple GPG keys associated with one email, the tool will not work.
Worse than not working, it may 'suddenly' stop working as you try to transfer a secret to someone, who then discovers that `git-secret` requires them to mess about with their GPG keyring in order to use the repository.

View File

@ -1,34 +0,0 @@
---
title: "git"
tags: [ "Documentation", "data", "git", "subtree" ]
---
## Pulling a Subtree from an existing git
The project has subdirectories `sub-1`, `sub-2`, `sub-3`.
The first should be its own repository, but should also retain its own history.
First, we extract its history as an independent item, and make that into a seprate branch.
```bash
git subtree split --prefix=sub-1 -b sub
```
If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3
Then go and create a new git somewhere else:
```bash
cd ..;mkdir sub-1;cd sub-1;git init --bare
```
Then go back to your initial git repo, and do the following:
git push ../subtest sub:master
Finally, you can clone this repo from your original.
```bash
git clone ../subtest
```