You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GitHub is slightly different than most code-hosting sites in the way that it namespaces projects. Instead of being primarily based on the project, GitHub is user centric. That means when I host my `grit` project on GitHub, you won’t find it at `github.com/grit` but instead at `github.com/schacon/grit`. There is no canonical version of any project, which allows a project to move from one user to another seamlessly if the first author abandons the project.
3
+
GitHub is slightly different than most code-hosting sites in the way that it namespaces projects.
4
+
Instead of being primarily based on the project, GitHub is user centric.
5
+
That means when I host my `grit` project on GitHub, you won’t find it at `github.com/grit` but instead at `github.com/schacon/grit`.
6
+
There is no canonical version of any project, which allows a project to move from one user to another seamlessly if the first author abandons the project.
4
7
5
-
GitHub is also a commercial company that charges for accounts that maintain private repositories, but anyone can quickly get a free account to host as many open source projects as they want. We’ll quickly go over how that is done.
8
+
GitHub is also a commercial company that charges for accounts that maintain private repositories, but anyone can quickly get a free account to host as many open source projects as they want.
9
+
We’ll quickly go over how that is done.
6
10
7
11
=== Setting Up a User Account
8
12
9
-
The first thing you need to do is set up a free user account. If you visit the Pricing and Signup page at `http://github.com/plans` and click the "Sign Up" button on the Free account (see figure 4-2), you’re taken to the signup page.
13
+
The first thing you need to do is set up a free user account.
14
+
If you visit the Pricing and Signup page at `http://github.com/plans` and click the ``Sign Up'' button on the Free account (see figure 4-2), you’re taken to the signup page.
10
15
11
16
image::images/18333fig0402-tn.png[Figure 4-2. The GitHub plan page.]
12
17
13
18
Here you must choose a username that isn’t yet taken in the system and enter an e-mail address that will be associated with the account and a password (see Figure 4-3).
14
19
15
20
image::images/18333fig0403-tn.png[Figure 4-3. The GitHub user signup form.]
16
21
17
-
If you have it available, this is a good time to add your public SSH key as well. We covered how to generate a new key in <<_generating_your_ssh_public_key>>. Take the contents of the public key of that pair, and paste it into the SSH Public Key text box. Clicking the "explain ssh keys" link takes you to detailed instructions on how to do so on all major operating systems.
18
-
Clicking the "I agree, sign me up" button takes you to your new user dashboard (see Figure 4-4).
22
+
If you have it available, this is a good time to add your public SSH key as well.
23
+
We covered how to generate a new key in <<_generating_your_ssh_public_key>>.
24
+
Take the contents of the public key of that pair, and paste it into the SSH Public Key text box.
25
+
Clicking the ``explain ssh keys'' link takes you to detailed instructions on how to do so on all major operating systems.
26
+
Clicking the ``I agree, sign me up'' button takes you to your new user dashboard (see Figure 4-4).
19
27
20
28
image::images/18333fig0404-tn.png[Figure 4-4. The GitHub user dashboard.]
21
29
22
30
Next you can create a new repository.
23
31
24
32
=== Creating a New Repository
25
33
26
-
Start by clicking the "create a new one" link next to Your Repositories on the user dashboard. You’re taken to the Create a New Repository form (see Figure 4-5).
34
+
Start by clicking the ``create a new one'' link next to Your Repositories on the user dashboard.
35
+
You’re taken to the Create a New Repository form (see Figure 4-5).
27
36
28
37
image::images/18333fig0405-tn.png[Figure 4-5. Creating a new repository on GitHub.]
29
38
30
-
All you really have to do is provide a project name, but you can also add a description. When that is done, click the "Create Repository" button. Now you have a new repository on GitHub (see Figure 4-6).
39
+
All you really have to do is provide a project name, but you can also add a description.
40
+
When that is done, click the ``Create Repository'' button.
41
+
Now you have a new repository on GitHub (see Figure 4-6).
Since you have no code there yet, GitHub will show you instructions for how create a brand-new project, push an existing Git project up, or import a project from a public Subversion repository (see Figure 4-7).
35
46
36
47
image::images/18333fig0407-tn.png[Figure 4-7. Instructions for a new repository.]
37
48
38
-
These instructions are similar to what we’ve already gone over. To initialize a project if it isn’t already a Git project, you use
49
+
These instructions are similar to what we’ve already gone over.
50
+
To initialize a project if it isn’t already a Git project, you use
39
51
40
52
$ git init
41
53
$ git add .
@@ -46,62 +58,89 @@ When you have a Git repository locally, add GitHub as a remote and push up your
Now your project is hosted on GitHub, and you can give the URL to anyone you want to share your project with. In this case, it’s `http://github.com/testinguser/iphone_project`. You can also see from the header on each of your project’s pages that you have two Git URLs (see Figure 4-8).
61
+
Now your project is hosted on GitHub, and you can give the URL to anyone you want to share your project with.
62
+
In this case, it’s `http://github.com/testinguser/iphone_project`.
63
+
You can also see from the header on each of your project’s pages that you have two Git URLs (see Figure 4-8).
50
64
51
65
image::images/18333fig0408-tn.png[Figure 4-8. Project header with a public URL and a private URL.]
52
66
53
-
The Public Clone URL is a public, read-only Git URL over which anyone can clone the project. Feel free to give out that URL and post it on your web site or what have you.
67
+
The Public Clone URL is a public, read-only Git URL over which anyone can clone the project.
68
+
Feel free to give out that URL and post it on your web site or what have you.
54
69
55
-
The Your Clone URL is a read/write SSH-based URL that you can read or write over only if you connect with the SSH private key associated with the public key you uploaded for your user. When other users visit this project page, they won’t see that URL—only the public one.
70
+
The Your Clone URL is a read/write SSH-based URL that you can read or write over only if you connect with the SSH private key associated with the public key you uploaded for your user.
71
+
When other users visit this project page, they won’t see that URL–only the public one.
56
72
57
73
=== Importing from Subversion
58
74
59
-
If you have an existing public Subversion project that you want to import into Git, GitHub can often do that for you. At the bottom of the instructions page is a link to a Subversion import. If you click it, you see a form with information about the import process and a text box where you can paste in the URL of your public Subversion project (see Figure 4-9).
75
+
If you have an existing public Subversion project that you want to import into Git, GitHub can often do that for you.
76
+
At the bottom of the instructions page is a link to a Subversion import.
77
+
If you click it, you see a form with information about the import process and a text box where you can paste in the URL of your public Subversion project (see Figure 4-9).
If your project is very large, nonstandard, or private, this process probably won’t work for you. In Chapter 7, you’ll learn how to do more complicated manual project imports.
81
+
If your project is very large, nonstandard, or private, this process probably won’t work for you.
82
+
In Chapter 7, you’ll learn how to do more complicated manual project imports.
64
83
65
84
=== Adding Collaborators
66
85
67
-
Let’s add the rest of the team. If John, Josie, and Jessica all sign up for accounts on GitHub, and you want to give them push access to your repository, you can add them to your project as collaborators. Doing so will allow pushes from their public keys to work.
86
+
Let’s add the rest of the team.
87
+
If John, Josie, and Jessica all sign up for accounts on GitHub, and you want to give them push access to your repository, you can add them to your project as collaborators.
88
+
Doing so will allow pushes from their public keys to work.
68
89
69
-
Click the "edit" button in the project header or the Admin tab at the top of the project to reach the Admin page of your GitHub project (see Figure 4-10).
90
+
Click the ``edit'' button in the project header or the Admin tab at the top of the project to reach the Admin page of your GitHub project (see Figure 4-10).
To give another user write access to your project, click the “Add another collaborator” link. A new text box appears, into which you can type a username. As you type, a helper pops up, showing you possible username matches. When you find the correct user, click the Add button to add that user as a collaborator on your project (see Figure 4-11).
94
+
To give another user write access to your project, click the ``Add another collaborator'' link.
95
+
A new text box appears, into which you can type a username.
96
+
As you type, a helper pops up, showing you possible username matches.
97
+
When you find the correct user, click the Add button to add that user as a collaborator on your project (see Figure 4-11).
74
98
75
99
image::images/18333fig0411-tn.png[Figure 4-11. Adding a collaborator to your project.]
76
100
77
101
When you’re finished adding collaborators, you should see a list of them in the Repository Collaborators box (see Figure 4-12).
78
102
79
103
image::images/18333fig0412-tn.png[Figure 4-12. A list of collaborators on your project.]
80
104
81
-
If you need to revoke access to individuals, you can click the "revoke" link, and their push access will be removed. For future projects, you can also copy collaborator groups by copying the permissions of an existing project.
105
+
If you need to revoke access to individuals, you can click the ``revoke'' link, and their push access will be removed.
106
+
For future projects, you can also copy collaborator groups by copying the permissions of an existing project.
82
107
83
108
=== Your Project
84
109
85
110
After you push your project up or have it imported from Subversion, you have a main project page that looks something like Figure 4-13.
86
111
87
112
image::images/18333fig0413-tn.png[Figure 4-13. A GitHub main project page.]
88
113
89
-
When people visit your project, they see this page. It contains tabs to different aspects of your projects. The Commits tab shows a list of commits in reverse chronological order, similar to the output of the `git log` command. The Network tab shows all the people who have forked your project and contributed back. The Downloads tab allows you to upload project binaries and link to tarballs and zipped versions of any tagged points in your project. The Wiki tab provides a wiki where you can write documentation or other information about your project. The Graphs tab has some contribution visualizations and statistics about your project. The main Source tab that you land on shows your project’s main directory listing and automatically renders the README file below it if you have one. This tab also shows a box with the latest commit information.
114
+
When people visit your project, they see this page.
115
+
It contains tabs to different aspects of your projects.
116
+
The Commits tab shows a list of commits in reverse chronological order, similar to the output of the `git log` command.
117
+
The Network tab shows all the people who have forked your project and contributed back.
118
+
The Downloads tab allows you to upload project binaries and link to tarballs and zipped versions of any tagged points in your project.
119
+
The Wiki tab provides a wiki where you can write documentation or other information about your project.
120
+
The Graphs tab has some contribution visualizations and statistics about your project.
121
+
The main Source tab that you land on shows your project’s main directory listing and automatically renders the README file below it if you have one.
122
+
This tab also shows a box with the latest commit information.
90
123
91
124
=== Forking Projects
92
125
93
-
If you want to contribute to an existing project to which you don’t have push access, GitHub encourages forking the project. When you land on a project page that looks interesting and you want to hack on it a bit, you can click the "fork" button in the project header to have GitHub copy that project to your user so you can push to it.
126
+
If you want to contribute to an existing project to which you don’t have push access, GitHub encourages forking the project.
127
+
When you land on a project page that looks interesting and you want to hack on it a bit, you can click the ``fork'' button in the project header to have GitHub copy that project to your user so you can push to it.
94
128
95
-
This way, projects don’t have to worry about adding users as collaborators to give them push access. People can fork a project and push to it, and the main project maintainer can pull in those changes by adding them as remotes and merging in their work.
129
+
This way, projects don’t have to worry about adding users as collaborators to give them push access.
130
+
People can fork a project and push to it, and the main project maintainer can pull in those changes by adding them as remotes and merging in their work.
96
131
97
-
To fork a project, visit the project page (in this case, mojombo/chronic) and click the "fork" button in the header (see Figure 4-14).
132
+
To fork a project, visit the project page (in this case, mojombo/chronic) and click the ``fork'' button in the header (see Figure 4-14).
98
133
99
-
image::images/18333fig0414-tn.png[Figure 4-14. Get a writable copy of any repository by clicking the "fork" button.]
134
+
image::images/18333fig0414-tn.png[Figure 4-14. Get a writable copy of any repository by clicking the ``fork'' button.]
100
135
101
136
After a few seconds, you’re taken to your new project page, which indicates that this project is a fork of another one (see Figure 4-15).
102
137
103
138
image::images/18333fig0415-tn.png[Figure 4-15. Your fork of a project.]
104
139
105
140
=== GitHub Summary
106
141
107
-
That’s all we’ll cover about GitHub, but it’s important to note how quickly you can do all this. You can create an account, add a new project, and push to it in a matter of minutes. If your project is open source, you also get a huge community of developers who now have visibility into your project and may well fork it and help contribute to it. At the very least, this may be a way to get up and running with Git and try it out quickly.
142
+
That’s all we’ll cover about GitHub, but it’s important to note how quickly you can do all this.
143
+
You can create an account, add a new project, and push to it in a matter of minutes.
144
+
If your project is open source, you also get a huge community of developers who now have visibility into your project and may well fork it and help contribute to it.
145
+
At the very least, this may be a way to get up and running with Git and try it out quickly.
146
+
In the next chapter, you'll learn more powerful tools and tips for dealing with complex situations, which will truly make you a Git master.
0 commit comments