Skip to content

Commit d243b0d

Browse files
authored
Merge pull request #169 from yuvipanda/best-practices
Add best practices recommendation documentation
2 parents 77488db + 31910e9 commit d243b0d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ Full Contents
9292
contributing
9393
topic/automatic-merging
9494
topic/url-options
95+
topic/repo-best-practices
9596
link

docs/topic/repo-best-practices.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Content git repository best practices
2+
3+
Sometimes, git's flexibility can lead to repositories that cause issues
4+
when used with nbgitpuller. Here are some recommendations to make your
5+
nbgitpuller experience smoother.
6+
7+
8+
## Never force push
9+
10+
Never use `--force` or `--force-with-lease` when pushing to your repositories.
11+
This is general good git practice, and unless you have [fairly deep
12+
understanding](https://xkcd.com/1597/) of how git works, it might screw up some
13+
of your users' local repositories beyond repair.
14+
15+
If you are using GitHub, you should enable [protected branches](https://docs.github.com/en/github/administering-a-repository/about-protected-branches)
16+
to prevent accidental force pushes.
17+
18+
## Prevent your repos from becoming huge
19+
20+
Larger git repos increase chances of timeouts and other intermittent failures
21+
that will be difficult to debug. They might leave your git repo in strange states
22+
too - contents fetched but not checked out, half-fetched, etc. Try and keep it small -
23+
under 100MB is great, under 1G is ok, but anything more is probably asking for trouble.
24+
25+
Large datasets are the biggest reason for increasing repository sizes. Try distribute
26+
datasets some other way, use a subset of data, or compress your data if you need to.
27+
28+
## Don't add `.ipynb_checkpoints` (and similar files) to your git repo
29+
30+
Jupyter uses a hidden `.ipynb_checkpoints` directory to temporarily autosave copies of the
31+
notebook. If you accidentally commit your local computer's copy of this to the git repo,
32+
it can cause hard to debug issues when students click nbgitpuller links. The students'
33+
Jupyter Notebook servers in the JupyterHub will also generate `.ipynb_checkpoints` for
34+
autosaving, and conflicts between these two can cause issues. Similar issues can happen
35+
with other temporary, hidden files - like `.DS_Store`, `__pycache__`, etc.
36+
37+
Adding `.ipynb_checkpoints` to your repo's `.gitignore` file will eliminate this
38+
class of issues completely. `git add` and similar commands will no longer
39+
accidentally include them in your repo. You can download this [python specific
40+
gitignore](https://github.com/github/gitignore/blob/master/Python.gitignore)
41+
file and put it in your repo as `.gitignore`, and it should take care of this.

0 commit comments

Comments
 (0)