Skip to content

Commit 9276afc

Browse files
committed
Add page on starting new repo
1 parent 642eb7b commit 9276afc

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ minimal guide to get started.
1616
install git, set up ssh.
1717
- [Typical use](pages/routine.html): add, commit, push, plus status
1818
and diff.
19-
- Start new repository: from scratch; using current project
19+
- [Start a new repository](pages/init.html): from scratch, or with an
20+
existing project.
2021
- [Contribute to someone's repository](pages/fork.html)
2122
- I want to fix a bug in someone's project
2223
- A package I'm using has a bug but I can't figure out how to fix it

pages/init.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
layout: page
3+
title: Start a new git repository
4+
---
5+
6+
Your first instinct, when you start to do something new, should be
7+
`git init`. You're starting to write a new paper, you're writing a
8+
bit of code to do a computer simulation, you mucking around with some
9+
new data ... _anything_: think `git init`.
10+
11+
### A new repo from scratch
12+
13+
Say you've just got some data from a collaborator and are about to
14+
start exploring it.
15+
16+
- Create a directory to contain the project.
17+
- Go into the new directory.
18+
- Type `git init`.
19+
- Write some code.
20+
- Type `git add` to add the files (see the
21+
[typical use page](routine.html)).
22+
- Type `git commit`.
23+
24+
The first file to create (and add and commit) is probably a ReadMe
25+
file, either as plain text or with
26+
[markdown](http://daringfireball.net/projects/markdown/), describing
27+
the project.
28+
29+
30+
### A new repo from an existing project
31+
32+
Say you've got an existing project on which you've not been using
33+
version control, and you want to start.
34+
35+
- Go into the directory containing the project.
36+
- Type `git init`.
37+
- Type `git add` to add all of the relevant files.
38+
- You'll probably want to create a `.gitignore` file right away, to
39+
indicate all of the files you don't want to track. Use `git add
40+
.gitignore`, too.
41+
- Type `git commit`.
42+
43+
44+
### Connect it to github
45+
46+
You've now got a local git repository. You can use git locally, like
47+
that, if you want. But if you want the thing to have a home on github, do
48+
the following.
49+
50+
- Go to [github](http://github.com).
51+
- Log in to your account.
52+
- Click the [new repository](https://github.com/new) button in the
53+
top-right. You'll have an option there to initialize the repository with a README
54+
file, but I don't.
55+
- Click the “Create repository” button.
56+
57+
Now, follow the second set of instructions, “Push an existing
58+
repository...”
59+
60+
$ git remote add origin git@github.com:username/new_repo.git
61+
$ git push -u origin master
62+
63+
Actually, the first line of the instructions will say
64+
65+
$ git remote add origin https://github.com/username/new_repo.git
66+
67+
But I've found that the `https://github...` bit doesn't work and I
68+
need to use `git@github...` I don't really understand the difference.

0 commit comments

Comments
 (0)