Skip to content

Commit 2feff7c

Browse files
committed
Merge pull request #5 from git-tips/doxie
Migrated to doxie ❤️
2 parents dd2031c + eff7432 commit 2feff7c

File tree

6 files changed

+133
-14
lines changed

6 files changed

+133
-14
lines changed

.doxie.render.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function escapeStr(str) {
2+
return str
3+
.replace(/\"/g, '\\"')
4+
.replace(/\n/g, '\\n');
5+
}
6+
7+
var render = function(data) {
8+
var data = data.data;
9+
10+
return [
11+
'## ' + data.title,
12+
'```sh',
13+
data.tip,
14+
'```',
15+
'\n'
16+
].join('\n');
17+
};
18+
19+
module.exports = render;

.doxie.render.toc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var tips = require('./tips.json');
2+
3+
var render = function(data) {
4+
var data = data.data;
5+
6+
var out = '* [' + data.title + '](https://github.com/git-tips/tips#' + data.title + ')\n';
7+
8+
if (tips[tips.length -1].title === data.title) out = out + '\n';
9+
return out;
10+
};
11+
12+
module.exports = render;

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,65 @@
1+
<!-- @doxie.inject start toc -->
2+
<!-- Don’t remove or change the comment above – that can break automatic updates. -->
3+
* [Overwrite pull](https://github.com/git-tips/tips#Overwrite pull)
4+
* [List of all the files changed in a commit](https://github.com/git-tips/tips#List of all the files changed in a commit)
5+
* [Git reset first commit](https://github.com/git-tips/tips#Git reset first commit)
6+
* [List all the conflicted files](https://github.com/git-tips/tips#List all the conflicted files)
7+
* [List all branches that are already merged into master](https://github.com/git-tips/tips#List all branches that are already merged into master)
8+
* [Quickly switch to the previous branch](https://github.com/git-tips/tips#Quickly switch to the previous branch)
9+
* [Remove branches that have already been merged with master](https://github.com/git-tips/tips#Remove branches that have already been merged with master)
10+
* [List all branches and their upstreams, as well as last commit on branch](https://github.com/git-tips/tips#List all branches and their upstreams, as well as last commit on branch)
11+
* [Track upstream branch](https://github.com/git-tips/tips#Track upstream branch)
12+
13+
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
14+
<!-- @doxie.inject end toc -->
15+
16+
17+
<!-- @doxie.inject start -->
18+
<!-- Don’t remove or change the comment above – that can break automatic updates. -->
119
## Overwrite pull
2-
320
```sh
4-
git fetch --all
5-
git reset --hard origin/master
21+
git fetch --all && git reset --hard origin/master
622
```
723

824
## List of all the files changed in a commit
9-
1025
```sh
1126
git ls-tree --name-only -r <commit-ish>
1227
```
1328

1429
## Git reset first commit
15-
1630
```sh
1731
git update-ref -d HEAD
1832
```
1933

2034
## List all the conflicted files
21-
2235
```sh
2336
git diff --name-only --diff-filter=U
2437
```
2538

2639
## List all branches that are already merged into master
27-
2840
```sh
29-
git checkout master
30-
git branch --merged
41+
git checkout master && git branch --merged
3142
```
3243

3344
## Quickly switch to the previous branch
34-
3545
```sh
3646
git checkout -
3747
```
3848

39-
# Remove branches that have already been merged with master
49+
## Remove branches that have already been merged with master
4050
```sh
41-
git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d
51+
git branch --merged | grep -v '\*' | xargs -n 1 git branch -d
4252
```
4353

4454
## List all branches and their upstreams, as well as last commit on branch
45-
4655
```sh
4756
git branch -vv
4857
```
4958

5059
## Track upstream branch
51-
5260
```sh
5361
git branch -u origin/mybranch
5462
```
63+
64+
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
65+
<!-- @doxie.inject end -->

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "tips",
3+
"version": "1.0.0",
4+
"description": "collection of git tips",
5+
"main": "index.js",
6+
"private": "true",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"precommit": "npm run generate && git add README.md",
10+
"update-readme": "echo 'Updating the readme…'; doxie --render < ./tips.json --inject into README.md && echo '…done!'",
11+
"update-toc": "echo 'Updating the table of contents…'; doxie --render .doxie.render.toc.js < ./tips.json --inject into README.md as toc && echo '…done!'",
12+
"generate": "npm run update-readme; npm run update-toc"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/npm-tips/tips.git"
17+
},
18+
"keywords": [
19+
"npm",
20+
"tips"
21+
],
22+
"contributors": [
23+
"hemanth"
24+
],
25+
"license": "MIT",
26+
"bugs": {
27+
"url": "https://github.com/git-tips/tips/issues"
28+
},
29+
"homepage": "https://github.com/git-tips/tips#readme",
30+
"devDependencies": {
31+
"doxie": "^0.2.2",
32+
"doxie.inject": "^0.1.1",
33+
"doxie.output": "^0.3.0",
34+
"doxie.render": "^0.3.0",
35+
"husky": "^0.8.1"
36+
}
37+
}

tips.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"title": "Overwrite pull",
4+
"tip": "git fetch --all && git reset --hard origin/master"
5+
},
6+
{
7+
"title": "List of all the files changed in a commit",
8+
"tip": "git ls-tree --name-only -r <commit-ish>"
9+
},
10+
{
11+
"title": "Git reset first commit",
12+
"tip": "git update-ref -d HEAD"
13+
},
14+
{
15+
"title": "List all the conflicted files",
16+
"tip": "git diff --name-only --diff-filter=U"
17+
},
18+
{
19+
"title": "List all branches that are already merged into master",
20+
"tip": "git checkout master && git branch --merged"
21+
},
22+
{
23+
"title": "Quickly switch to the previous branch",
24+
"tip": "git checkout -"
25+
},
26+
{
27+
"title": "Remove branches that have already been merged with master",
28+
"tip": "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
29+
},
30+
{
31+
"title": "List all branches and their upstreams, as well as last commit on branch",
32+
"tip": "git branch -vv"
33+
},
34+
{
35+
"title": "Track upstream branch",
36+
"tip": "git branch -u origin/mybranch"
37+
}
38+
]

0 commit comments

Comments
 (0)