22,99 €
Code collaboratively with GitHub Once you've learned the basics of coding the next step is to start sharing your expertise, learning from other coding pros, or working as a collaborative member of development teams. GitHub is the go-to community for facilitating coding collaboration, and GitHub For Dummies is the next step on your journey as a developer. Written by a GitHub engineer, this book is packed with insight on how GitHub works and how you can use it to become a more effective, efficient, and valuable member of any collaborative programming team. * Store and share your work online with GitHub * Collaborate with others on your team or across the international coding community * Embrace open-source values and processes * Establish yourself as a valuable member of the GitHub community From setting up GitHub on your desktop and launching your first project to cloning repositories, finding useful apps on the marketplace, and improving workflow, GitHub For Dummies covers the essentials the novice programmer needs to enhance collaboration and teamwork with this industry-standard tool.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 414
Veröffentlichungsjahr: 2019
GitHub® For Dummies®
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2019 by John Wiley & Sons, Inc., Hoboken, New Jersey
Media and software compilation copyright © 2019 by John Wiley & Sons, Inc. All rights reserved.
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. Github is a registered trademark of Github, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2019938575
ISBN 978-1-119-57267-1 (pbk); ISBN 978-1-119-57266-4 (ePDF); ISBN 978-1-119-57265-7 (epub)
Cover
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Part 1: Getting Started with GitHub.com
Chapter 1: Understanding the Git in GitHub
Introducing GitHub
Understanding Version Control
Git Version Control
Git's Place on GitHub
Signing Up for GitHub.com
Personalizing Your GitHub.com Account
Discovering Helpful Resources
Chapter 2: Setting Up Your Collaborative Coding Environment
Exploring GitHub.com
Understanding Your Profile
Getting to Know GitHub Desktop
Setting up GitHub Desktop
Introducing Atom
Part 2: Starting Your First Solo Project
Chapter 3: Introducing GitHub Repositories
Setting Up a Repository
Exploring Your Repository
Modifying README.md
Merging a Pull Request
Using Issues and Project Boards
Chapter 4: Setting Up a GitHub Website Repo
Introducing GitHub Pages
Turning a Project Repo into a Website
Setting Up a Personal Website Repo
Creating Issues for Your Website
Setting Up Your Local Environment
Finding Resources for GitHub Pages
Chapter 5: Creating a Website with GitHub Pages
Jumping into an Existing GitHub Project
Preparing Your Contribution
Building Your Personal Website
Part 3: Contributing to Your First Project
Chapter 6: Forking GitHub Repositories
Introducing Forking
Cloning, Forking, and Duplicating
Cloning a Repository
Forking a Repository
Chapter 7: Writing and Committing Code
Creating a Repository
Writing Code
Creating a Commit
Writing a Good Commit Message
Committing Code with GitHub Desktop
Using GitHub Conventions in Commit Messages
Committing Code from Your Editor
Chapter 8: Working with Pull Requests
Understanding a Pull Request
Pushing Code to GitHub
Opening a Pull Request
Writing a Great Pull Request
Reviewing a Pull Request
Reading More About Pull Requests
Part 4: Manage and Contribute to Large Projects
Chapter 9: Exploring and Contributing to OSS
Exploring GitHub
Finding Places to Contribute
Surveying a Project for Contribution
Setting Contributor Expectations
Keeping Tabs on a Project
Chapter 10: Starting Your Own OSS
Creating an Open Source Repository
Making a Repository Public
Enforcing a Code of Conduct
Writing a README.md File
Writing Good Documentation
Managing Issues
Ending Your Project
Chapter 11: Inner-Source Your Code on GitHub
Why Code in Private?
Using GitHub Organizations
Making the Most of Your Teams
Best Practices for Inner-Sourcing
Part 5: Make GitHub Work For You
Chapter 12: Collaborating Outside of GitHub
Chatting It Up
Getting Trello and GitHub Integrated
Managing Notifications with Octobox
Chapter 13: GitHub Workflow Integrations
Using GitHub for Atom
Using GitHub for Visual Studio Code
Using GitHub for Unity
Using GitHub for Visual Studio
Using GitHub for XCode
Using GitHub for IntelliJ
Chapter 14: Personalizing GitHub
Using Browser Extensions
GitHub Apps and Probot
Taking Action with GitHub Actions
Part 6: The GitHub Ecosystem
Chapter 15: Exploring the GitHub Marketplace
Introducing the GitHub Marketplace
Listing Your App on the Marketplace
Considering Common Apps to Install
Chapter 16: GitHub and You
Understanding Your GitHub Profile
Starring Repositories
Following Users
Chapter 17: Attending Events
Exploring Types of Events
Knowing What to Expect at Events
Becoming Familiar with GitHub Events
Speaking at Events
Finding Funding for Events
Part 7: The Parts of Tens
Chapter 18: Ten Ways to Level Up on GitHub
Trial and Error
GitHub Help Docs
GitHub Learning Labs
GitHub In-Person Training
Project-Specific Documentation
External Community Places
Online Coding Tutorials
Online Courses and Tutorials
Blogs and Twitter
Community Forum
Chapter 19: Ten Ways to Improve Your Development Workflow
Drafting Pull Requests
Git Aliases
Run Tests Automatically
Take Breaks
Prototype User Interfaces
Scaffold Apps with Yeoman
Chrome Web Developer Tools
StackOverflow
Code Analysis Tools
Project Boards
Chapter 20: Ten Tips for Being an Effective Community Member
Be Respectful and Kind
Report Bad Behavior
Write Good Bug Reports
Be Responsive
Submit Pull Requests to Correct Documentation
Document Your Own Code
Give Credit Where It's Due
Help Get the Word Out
Be Proactive and Mentor Others
Contribute Outside of GitHub
Index
About the Authors
Advertisement Page
Connect with Dummies
End User License Agreement
Chapter 1
FIGURE 1-1: Example workflow for Git branches.
FIGURE 1-2: The GitHub.com home page when you’re logged in.
FIGURE 1-3: The Personal Settings page.
FIGURE 1-4: Account settings.
FIGURE 1-5: The Email settings.
FIGURE 1-6: The Notifications settings.
FIGURE 1-7: The Billing settings.
FIGURE 1-8: The place to create SSH and GPG keys.
FIGURE 1-9: The Saved replies settings.
Chapter 2
FIGURE 2-1: The home page of GitHub.com.
FIGURE 2-2: The top menu bar of GitHub.com.
FIGURE 2-3: ProTip found on the Pull request page.
FIGURE 2-4: Curated list of repositories on GitHub.com.
FIGURE 2-5: My profile.
FIGURE 2-6: The GitHub Desktop application default view.
FIGURE 2-7: The Sign in dialog box for the GitHub Desktop application.
FIGURE 2-8: The Atom application default view.
FIGURE 2-9: the Squirrel icon takes you to the About page where you can update A...
FIGURE 2-10: Keyboard bindings for toggling the Git and GitHub tabs.
FIGURE 2-11: The Atom Settings page.
Chapter 3
FIGURE 3-1: The page to create a new repository.
FIGURE 3-2: The home page of my HelloWorld repository.
FIGURE 3-3: The Insights tab.
FIGURE 3-4: The Code tab.
FIGURE 3-5: The page to add a file to the
HelloWorld
repository.
FIGURE 3-6: The Open a pull request page.
FIGURE 3-7: The pull request description page for an open pull request.
FIGURE 3-8: The
README.md
file in
edit
mode.
FIGURE 3-9: The
README.md
file in
diff
mode.
FIGURE 3-10: The
README.md
file in
diff
mode with the headshot added.
FIGURE 3-11: My pull request page.
FIGURE 3-12: The diff in split view.
FIGURE 3-13: The dialog box to confirm the merge of the pull request.
FIGURE 3-14: The merge confirmation for a pull request.
FIGURE 3-15: The page to create a new project.
FIGURE 3-16: A blank kanban project board template.
FIGURE 3-17: The automation settings for the To do column on a kanban project.
FIGURE 3-18: The page that shows all issues for the
HelloWorld
repository.
FIGURE 3-19: A new issue linked to the project Tracking Changes to HelloWorld.
FIGURE 3-20: The description page of an open issue.
FIGURE 3-21: The project board with an open issue and an open pull request.
FIGURE 3-22: The diff of
README.md
showing the added text.
Chapter 4
FIGURE 4-1: The GitHub Pages section under repository settings.
FIGURE 4-2: The GitHub Pages website theme chooser.
FIGURE 4-3: The issue list for the website repository.
FIGURE 4-4: The project board for the website repository.
FIGURE 4-5: An overview of GitHub Desktop.
FIGURE 4-6: An overview of Atom.
Chapter 5
FIGURE 5-1: Places to find GitHub repos on the GitHub.com home page.
FIGURE 5-2: Commit changes box when you have write permissions on a repo.
FIGURE 5-3: Warning and commit box when you have read-only permissions on a repo...
FIGURE 5-4: The place to start a review of a pull request.
FIGURE 5-5: The button to create a new branch in GitHub Desktop for a specific r...
FIGURE 5-6: The branch selector in Atom showing that the correct branch is check...
FIGURE 5-7: Editing a file in Atom.
FIGURE 5-8: Staging and committing changes in Atom.
FIGURE 5-9: GitHub.com indicates when a branch is ready to be merged.
Chapter 6
FIGURE 6-1: GitHub.com error message if you don’t have edit permissions on a rep...
FIGURE 6-2: A forked repo on GitHub.com.
FIGURE 6-3: Original, upstream repo detecting a new branch from a forked repo.
FIGURE 6-4: Forked repo detecting a new branch.
FIGURE 6-5: Forked repo detecting a new pull request with the option for upstrea...
FIGURE 6-6: Pull request without the option to merge.
FIGURE 6-7: Pull request with the option to merge.
FIGURE 6-8: Push permission error message in Atom.
FIGURE 6-9: Push permission error message in GitHub Desktop.
Chapter 7
FIGURE 7-1: An alert message from our running code.
FIGURE 7-2: A list of commit messages, some with emojis in the summary.
FIGURE 7-3: GitHub Desktop opened to the
best-example
repository.
FIGURE 7-4: The Publish dialog box used to publish a repository to GitHub.com.
FIGURE 7-5: The Changes View showing the uncommitted changes.
FIGURE 7-6: The diff view with one change selected.
FIGURE 7-7: The Changes tab after a partial commit.
FIGURE 7-8: The emoji picker listing emojis.
FIGURE 7-9: A list of issues with the word “alert” in them.
FIGURE 7-10: A list of potential coauthors.
FIGURE 7-11: The newly created commit.
Chapter 8
FIGURE 8-1: Repository home page with recently pushed branches listed.
FIGURE 8-2: The Open a pull request page.
FIGURE 8-3: List of potential reviewers with two reviewers selected.
FIGURE 8-4: A created pull request.
FIGURE 8-5: Details section collapsed.
FIGURE 8-6: Details section expanded.
FIGURE 8-7: Uploading an image to a pull request.
FIGURE 8-8: Message requesting your review on this pull request.
FIGURE 8-9: Pull request with failed checks.
FIGURE 8-10: Pull Request Comment form for a line of code.
FIGURE 8-11: Pending comment in a pull request review.
FIGURE 8-12: Comment form with the Suggest changes button.
FIGURE 8-13: Comment with a suggested change.
FIGURE 8-14: Comment with a suggested change.
FIGURE 8-15: Comment with a suggested change.
Chapter 9
FIGURE 9-1: The Explore page on GitHub.
FIGURE 9-2: The Discover page on GitHub with repository recommendations.
FIGURE 9-3: List of topics for a repository.
FIGURE 9-4: A list of suggested topics.
FIGURE 9-5: Topic page for NodeJS.
FIGURE 9-6: Profile page for Phil, one of the authors.
FIGURE 9-7: Up for grabs filter.
FIGURE 9-8: Visual Studio Code Issues filtered by the
good first issue
label.
Chapter 10
FIGURE 10-1: Home page for our soon-to-be open source repository.
FIGURE 10-2: Choose a license template button magically appears.
FIGURE 10-3: The license chooser page.
FIGURE 10-4: The license information page.
FIGURE 10-5: Danger zone: where you can make a private repo public.
FIGURE 10-6: Confirmation to convert a private repo public.
FIGURE 10-7: The set of interaction limits.
FIGURE 10-8: Profile page with link to block or report user.
FIGURE 10-9: Dialog box with Block user and Report abuse buttons.
FIGURE 10-10: Serving a GitHub Pages site from the docs folder.
FIGURE 10-11: Unlabeled issues filter.
FIGURE 10-12: Choosing an issue template.
FIGURE 10-13: Choosing an issue template.
FIGURE 10-14: Choose an issue template to create an issue.
FIGURE 10-15: A new issue with the Bug report template filled in.
FIGURE 10-16: Creating a new saved reply.
FIGURE 10-17: Selecting a saved reply in a comment box.
FIGURE 10-18: The button to archive a repository.
FIGURE 10-19: The button to archive a repository.
FIGURE 10-20: The transfer repository dialog box.
Chapter 11
FIGURE 11-1: Inviting someone to join your organization.
FIGURE 11-2: Invitation request from the invitee’s account.
FIGURE 11-3: Repositories associated with the Microsoft organization.
FIGURE 11-4: A list of members of an organization.
FIGURE 11-5: An overview of a member of an organization.
FIGURE 11-6: Creating a project board linked with multiple repositories.
FIGURE 11-7: Settings for organization project boards.
FIGURE 11-8: Options for blocking an individual.
FIGURE 11-9: Options for blocking an individual.
FIGURE 11-10: Repository access for a specific team.
FIGURE 11-11: Requiring at least one approving review from a CODEOWNER.
FIGURE 11-12: CODEOWNERS automatically added to a pull request.
FIGURE 11-13: GitHub must have read access to your repository to give security a...
FIGURE 11-14: Allow GitHub read access to your repository for various data servi...
FIGURE 11-15: The network graph for the GitHub package for Atom open source proj...
Chapter 12
FIGURE 12-1: Confirmation page for the GitHub app.
FIGURE 12-2: Choose which channels the GitHub app is enabled in.
FIGURE 12-3: Slack message with a prompt to connect your GitHub account.
FIGURE 12-4: Authorize the Slack app for GitHub.
FIGURE 12-5: Configuring the Slack app on GitHub.
FIGURE 12-6: Summary of available GitHub commands on Slack.
FIGURE 12-7: Slack dialog to create an issue on GitHub.
FIGURE 12-8: Slack message with information about a newly created GitHub issue.
FIGURE 12-9: Power-Ups section of the menu.
FIGURE 12-10: Authorize Trello on GitHub.
FIGURE 12-11: Trello card with a GitHub power-up.
FIGURE 12-12: Selecting the issue to attach.
FIGURE 12-13: Trello card with an issue and pull request attached.
FIGURE 12-14: Front of a card with an issue and pull request attached.
FIGURE 12-15: GitHub issue with a link to the Trello board.
FIGURE 12-16: GitHub app download button and Pricing options for Octobox.
FIGURE 12-17: Octobox inbox for the author.
Chapter 13
FIGURE 13-1: The GitHub tab when no project is open in Atom.
FIGURE 13-2: The GitHub tab when a GitHub project is open in Atom, but you have ...
FIGURE 13-3: The GitHub tab showing all open pull requests on that repository.
FIGURE 13-4: The detailed view of a pull request with the Checkout button.
FIGURE 13-5: The GitHub tab showing the current pull request at the top.
FIGURE 13-6: The GitHub tab showing the current pull request at the top.
FIGURE 13-7: GitHub issue details opened in Atom.
FIGURE 13-8: GitHub extension for VS Code in the extension marketplace.
FIGURE 13-9: Three ways to start the GitHub sign-in process.
FIGURE 13-10: Interacting with pull requests in VS Code.
FIGURE 13-11: Adding an inline comment in VS Code.
FIGURE 13-12: GitHub for Unity in the Asset Store.
FIGURE 13-13: Installing the GitHub for Unity extension.
FIGURE 13-14: Signing in to GitHub inside of Unity.
FIGURE 13-15: Publishing your project to GitHub.com.
FIGURE 13-16: The GitHub for Visual Studio extension in the Visual Studio Market...
FIGURE 13-17: The Team Explorer pane with the GitHub Connect section.
FIGURE 13-18: The Team Explorer pane with additional GitHub project options.
FIGURE 13-19: A list of pull requests on the GitHub pane.
FIGURE 13-20: Interacting with a pull request in Visual Studio.
FIGURE 13-21: Signing in to GitHub inside of XCode.
FIGURE 13-22: List of GitHub repositories you have access to clone from inside X...
FIGURE 13-23: Clone from a git project to get started integrating GitHub into In...
FIGURE 13-24: List of GitHub repositories you have access to clone from inside I...
FIGURE 13-25: Viewing a pull request from inside of IntelliJ.
FIGURE 13-26: Creating a pull request from inside of IntelliJ.
Chapter 14
FIGURE 14-1: Configuring the Refined GitHub extension.
FIGURE 14-2: Taking a short video with GitHub Selfie.
FIGURE 14-3: The README page of a Glitch Probot app.
FIGURE 14-4: Updating the event subscriptions for the GitHub app.
FIGURE 14-5: The why not both app in action.
FIGURE 14-6: The landing page for GitHub Actions workflows.
FIGURE 14-7: Committing a simple workflow.
Chapter 15
FIGURE 15-1: Your Settings page on GitHub.com where you can add payment informat...
FIGURE 15-2: Your applications that you can turn into Marketplace listings.
FIGURE 15-3: Filling out a form to list an app.
FIGURE 15-4: Steps to fill out a Marketplace submission.
FIGURE 15-5: AppVeyor CI app example on the GitHub for Visual Studio repository.
FIGURE 15-6: Codecov app example on the GitHub package for Atom repository.
FIGURE 15-7: Greenkeeper app example on the GitHub package for Atom repository.
Chapter 16
FIGURE 16-1: The profile page for Haacked.
FIGURE 16-2: Changing your status message.
FIGURE 16-3: Staff badge on a GitHub profile.
FIGURE 16-4: Displaying private contributions and the activity graph.
FIGURE 16-5: Profile visualization for one of the authors.
Chapter 18
FIGURE 18-1: Giving the GitHub Learning Lab app access to a specific repository.
FIGURE 18-2: Effective pull request review feedback on the VS Code open source p...
Chapter 19
FIGURE 19-1: Drafting a pull request.
FIGURE 19-2: The ready for review button.
Cover
Table of Contents
Begin Reading
iii
iv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
345
346
347
348
349
350
351
352
353
354
355
Welcome to the world of collaborative coding! Whether you’re just starting your coding journey, building fairly complex programs, or building with a team of people, this book guides you in using one of the most used tools for collaborative code-writing; GitHub.com. With more than 31 million users and over 100 million repositories (projects) hosted, GitHub.com is the No. 1 place to build and collaborate on code.
Though you spend many hours sitting at your computer, alone, debugging and writing code, the ideal coding team includes more than just you. Hundreds of developers spent more than four years building World of Warcraft before its first release in 2004. Although occasionally you can build a big hit like Flappy Bird alone, in a couple of days, the norm for software development is that you will work with other coders, designers, testers, user experience experts, product managers, and sometimes hardware engineers to bring something to the hands of users.
When you’re first starting out on complex coding projects, understanding effective ways to collaborate can be daunting. This book introduces you to the world of open source development (the epitome of collaboration), as well as effective ways to work with one other person — or even yourself over the course of many years! (I don’t know about you, but Sarah from three years ago knows stuff that Sarah from today can’t remember, and Sarah from today has more experience than Sarah from three years ago.)
GitHub For Dummies is written as a reference guide. Each part introduces you to a different aspect of collaborative coding. So if you’re experienced in using GitHub, but you’re new to the open source community, you can jump to Part 5 and skip some of the GitHub basics.
As you explore each part of this book, keep the following points in mind:
Words that are being defined appear in
italic.
Code and URLs (web addresses) are shown in
monofont
.
Command sequences using onscreen menus use the command arrow. For example, when working in Scratch, you can open a new project as follows: From the menu bar, choose File ⇒ New.
The figures you see in this book use Mac and Chrome. We provide some tips when what you see on a Windows PC may be different, but you should see the same things, regardless of which Internet browser you use.
In this book, I make some assumptions that very well may be foolish, about you, your coding experience, and your goals.
You're interested in and have had some experience with coding. You don’t have to be an expert coder, but you have made a Hello World application (or the equivalent) in at least one programming language.
You have patience and determination and are resourceful. When you’re presented with a challenge, you can Google your way to finding a solution. This book guides you through GitHub.com as it exists at the time of writing it, but new features and workflows are being created, and part of your collaborative coding journey is to discover how to use those new features as they become available.
You have experience with a keyboard and mouse on either Mac or Windows PC and have access to one of those machines.
You’re capable of using an Internet browser, such as Safari, Chrome, or Firefox, and you can type a URL to access a website, such as GitHub.com.
You know how to install applications on your computer. Although we guide you through anything that is unique to the setup, you should know how to download and install an application without step-by-step guidance.
Throughout the margin of this book are small images, known as icons. These icons mark important tidbits of information:
The Tip icon identifies places where we offer additional tips for making this journey more interesting or clear. Tips can start you on a rabbit hole down another workflow, not covered in this book, or cover some neat shortcuts that you may not have known about.
The Remember icon bookmarks to important ideas to help you work more effectively throughout this book.
The Warning icon helps protect you from common errors and may even give you tips to undo your mistakes.
In addition to what you’re reading right now, this product also comes with a free access-anywhere Cheat Sheet that covers common commands and GitHub actions. To get this Cheat Sheet, simply go to www.dummies.com and search for “GitHub For Dummies Cheat Sheet” in the Search box.
Other online resources also pair with this book:
Online articles covering additional topics are available at
www.dummies.com/extras/github
.
Updates to this book, if any, can be found at
www.dummies.com/extras/github
.
GitHub Learning Labs are free, guided tutorials that can be installed and found at
https://lab.github.com
.
GitHub is a tool used by millions of developers. The workflows that you discover in this book is just the beginning. As you become a more experienced coder, begin to collaborate on more elaborate projects, or join different companies and teams, you may encounter new workflows that use these tools in different ways. You should feel empowered to explore! Visit https://help.github.com or https://guides.github.com for guidance and don’t forget to follow the blog at https://blog.github.com/ to stay up to date with all of the new features!
Part 1
IN THIS PART …
Discover how to use Git on your local computer to track changes in your project.
Sign up for a free GitHub.com account.
Explore GitHub.com resources and features.
Install GitHub Desktop to manage the link between your local and remote projects.
Install the GitHub Atom editor as a lightweight option for coding.
Prepare for creating your own projects and contributing to others.
Chapter 1
IN THIS CHAPTER
Getting familiar with GitHub
Discovering Git
Signing up with GitHub.com
Exploring helpful resources
Whether you’re an experienced coder or a newbie starting out, learning how to work with others on code is critical to succeeding in the software industry. Millions of people around the world work together to build software, and GitHub is one of the largest tools to support a collaborative workflow. This chapter introduces you to the core tools you need to write code with other people.
GitHub creates an environment that allows you to store your code on a remote server, gives you the ability to share your code with other people, and makes it easy for more than one person to add, modify, or delete code to the same file and project, while keeping one source of truth for that file (phew!). So what does that all actually mean? One of my favorite ways of explaining GitHub.com to folks who are new to the tool is to compare it to Google Docs — a place online where you can write code with other people and not have to email different versions back and forth.
What makes GitHub work behind the scenes is Git.
Version control systems (also known as source control management, or SCM) are software that keep track of each version of each file in a coding project, a timestamp for when that version was created, and the author of those changes.
Writing code is an iterative process. For example, when you’re building a website, you first may want to get some basic structure up before adding all your content. The best thing to do is to create a version of your website each time you have something that works. That way, as you experiment with the next piece, if something breaks, you can just go back to your previous version and start over.
SCMs enable coders to make mistakes without worrying that they’ll have to completely start over. Think of it like being able to click Undo, but instead of undoing each key press, you can undo an entire piece of the project if you decide you don’t like it or it doesn’t work.
The basic workflow of coding with version control system support is as follows:
Create a project, typically in a folder on your computer.
Tell your version control system of choice to track the changes of your project/folder.
Each time your project is in a working state, or you’re going to walk away from it, tell your version control system of choice to save it as the next version.
If you ever need to go back to a previous version, you can ask your version control system to revert to whichever previous version you need.
You can use a version control system if you’re working alone on your own computer, but it gets even more interesting when you begin working with other people. (For more on working with other people, see the section “Git version control,” later in this chapter).
For more information about version control, visit https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control.
GitHub, as the same would suggest, is built on Git. Git is a type of version control system, and it is free and open source, which means that anyone can use it, build on top of it, and even add to it.
GitHub products make using Git easy, but if you’re curious, you can also use Git to track your solo projects on your computer. You can find a brief introduction to local Git commands for solo projects in the section “Try simple Git on the terminal”.
With the help of Git for Windows, using the terminal on Mac, Windows, or Linux computers is exactly the same. A terminal is an application that enables you to interact with your computer in a text-based way — in other words, instead of double-clicking and dragging, you type commands to navigate your computer.
If you’re on Mac or Linux, a terminal is already installed on your computer. If you’re using a Windows computer, install Git for Windows, which is what this section assumes you’ve installed. Just go to https://gitforwindows.org and click Download to gain access to Git Bash, an emulator that allows you to interact with Git just like you would on a Linux or Mac terminal. You also get Git GUI, which gives you a user interface for almost all Git commands you might type into Git Bash, and shell integration so that you can quickly open Git Bash or Git GUI from any folder.
Many developers on Windows prefer to use PowerShell as their terminal environment. You can use Git within PowerShell, but setting that up properly is outside the scope of this book. However, Phil, one of the authors, has a handy guide to setting this up at https://haacked.com/archive/2011/12/13/better-git-with-powershell.aspx.
First, find the Terminal application:
On Mac, you can click the magnifying glass at the top right of your desktop, type
Terminal
, select the terminal from the list of applications, and press Enter or click it.
On Linux, press Ctrl-Alt-T all at the same time, and the terminal window opens.
On Windows, click the Windows menu in the bottom right of your desktop, search
Git Bash,
select the Git Bash application from the list of search results, and press Enter or click it.
When the application opens, type git --version in the terminal. If you have Git installed, you should see a version number, as shown in the following code (the $ should already be on the line, so you do not need to type it). Otherwise, you can follow the instructions on https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.
When using the command line, you have to be very careful about exactly what you're typing. In the following code, the first instruction is for you to type git --version. You should note that a space appears between git and the rest of the instruction but no other spaces. You should also note the two dashes before the word version. They can be easy to miss, so be careful!
For Mac or Linux, you should see something like this:
$ git --version
git version 2.16.3
$
For Windows, you should see something like this:
$ git --version
git version 2.20.1.windows.1
$
Next, using the terminal, go to your desktop and create a new folder called git practice. To do this, you should type the following commands:
$ cd ~/Desktop
$ mkdir git-practice
$ cd git-practice
$
If you type pwd, you should see that you are now in the folder git-practice, which is on your desktop. It might look something like this:
$ pwd
$ /Users/sguthals/Desktop/git-practice
$
Now, you can tell git to track this folder using the init command.
$ git init
Initialized empty Git repository in /Users/sguthals/Desktop/git-practice
$
Then make sure that you have a clean folder. You can check with the status command:
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
$
Then, you can create a file to have Git start tracking and confirm the file is in the folder:
$ echo "practicing git" > file.txt
$ ls
file.txt
$
On Mac, you can open this folder in a Finder with the open <path> command:
$ open .
$
On Linux, you can open this folder with the nautilus <path> command:
$ nautilus .
$
On Windows, you can open this folder with the explorer <path> command:
$ explorer .
$
In this example, we put . as the <path> for each command. . tells the terminal to open the current folder. You could also use a different path with these commands to open other folders.
After the folder is open, double-click the file called file.txt, and the file opens with TextEdit on Mac, gedit on Linux, and Notepad on Windows. You can see that the words “practicing git” are actually there.
Close the file. Now, you can tell Git that you want to save this as a particular version. Back in the terminal:
$ git add file.txt
$ git commit -m "Adding my file to this version"
[master (root-commit) 8d28a21] Adding my file to this version
1 file changed, 1 insertion(+)
Create mode 100644 file.txt
$ git status
On branch master
nothing to commit, working tree clean
$
You can make a change to your file in the text file. Open the file again, change the text to say “Hi! I'm practicing git today!” and then click File ⇒ Save and close the text application.
When you go back to the Terminal to check the status of your project again, you should see that Git has noticed that the file has changed:
$ git status
On branch master
Changed not staged for commit:
(use "git add <file…" to update what will be committed)
{use "git checkout -- <file>…" to discard changed in working directory)
modified: file.txt
no changed added to commit (use "git add" and/or "git commit -a")
$
Commit this version of your file again and notice that Git recognizes that everything has been saved to a new version:
$ git add file.txt
$ git commit -m "I changed the text"
[master 6d80a2a] I changed the text
1 file changed, 1 insertion(+), 1 deletion(-)
$ git status
On branch master
nothing to commit, working tree clean
$
If your terminal starts to get too cluttered, you can type clear to clear some space and make it more visually appealing. Don't worry; you can always scroll up and see everything you typed earlier!
Say that you actually want to go see the original change; when you added “practicing git”. First, get the log of all the commits you have made:
$ git log
commit 6d80a2ab7382c4d308de74c25669f16d1407372d (HEAD -> master)
Author: sguthals <[email protected]>
Date: Sun Dec 9 08:54:11 2018 -0800
I changed the text
commit 8d28a21f71ec5657a2f5421e03faad307d9eec6f
Author: sguthals <[email protected]>
Date: Sun Dec 9 08:48:01 2018 -0800
Adding my file to this version
$
Then ask Git to show you the first commit you made (the bottom most one). Make sure that you're typing your unique commit hash. In this book, the hash starts with 8d28a2. Make sure you type the entire hash that appears in your Git log:
Instead of typing the entire hash (and possibly having a typo), you can highlight the hash with your mouse, right-click and choose copy, and then after git checkout, you can right-click and choose Paste. Using the keyboard shortcuts Ctrl+C or ⌘ -C doesn't work
$ git show 8d28a21f71ec5657a2f5421e03faad307d9eec6f
commit 8d28a21f71ec6567a2f5421e03faad307d9eec6f
Author: sguthals <[email protected]>
Date: Sun Dec 9 08:48:01 2018 -0800
Adding my file to this version
diff --git a/file.txt b/file.txt
new file mode 100644
index 0000000..849a4c7
--- /dev/null
+++ b/file.txt
@@ -0,0 +1 @@
+practicing git
$
You can see that practicing git was added to the file in that original commit.
For more information on how to use git on the command line, check out the following resources:
The GitHub Git Cheat Sheet at
https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf
The Visual Git Cheat Sheet at
http://ndpsoftware.com/git-cheatsheet.html
The Git Docs page at
https://git-scm.com/doc
Another couple resources for learning and understanding Git is https://learngitbranching.js.org and http://git-school.github.io/visualizing-git, which enable users on Windows to experience a similar workflow because they’re visualizations hosted on a website. The first link, learninggitbranching.js.org, is a good self-guided set of exercises, while the second link, git-school, is best used for folks who have a decent understanding of Git and want to explore what will happen in different scenarios, or for folks who have a more expert Git user guiding them.
Git is different from other version control systems because it has fast branching, shown in Figure 1-1. Branching is a Git function that essentially copies code (each branch is a copy of the code), allows you to make changes on a specific copy, and then merges your changes back into the main (master) branch.
FIGURE 1-1: Example workflow for Git branches.
When you're writing code, you will add files and commit changes to your master branch. Figure 1-1 outlines a specific workflow where two people are collaborating on the same file. Person 1 creates a new branch called MyBranch and makes some changes to the file. Person 2 also creates a new branch called YourBranch and makes some changes to the same file. You can see this change in box #1.
You can see the difference (called diff) between the master branch and MyBranch in Figure 1-1 in box #2.
Then, Person 1 merges their changes with the master branch, as you can see in box #3.
Person 2 has made their own changes, but before merging, they will make sure they have the most updated version of the master branch, which now has the changes from Person 1. The diff can be seen in box #4. Notice what text is in both files.
Finally, Person 2 acknowledges that their changes will overwrite Person 1's changes and merges their changes with master, making the final version have the changes from Person 2. Box #5 shows this final merge, with the master branch having the final changes.
Figure 1-1 shows just one workflow that can exist when more than one person is working on code and is meant to describe branching. You can get a more in-depth overview on Git and branching at https://git-scm.com.
Another common way to use branching is to have each feature that you develop be on a different branch, regardless of the collaborator who is building the feature.
You can extend the idea of branching by feature to also have one branch that is your production branch. This branch is what your users will see. Then you can have a development branch, which is one that you can merge features into without changing what your users see.
This type of branching allows you to build a lot of different features, merge them each into the developmentbranch, make sure they all work the way you want, and then merge the development branch into the production branch when you know it's ready for your users.
You can also create branches to test to see whether something works and then completely throw the branch away.
This type of branching can be useful if you want to try a completely new layout of a website, for example. You can create three different branches, each with a different layout. After you decide which layout you like best, you can simply delete the other two branches and merge the branch with your favorite layout into master.
GitHub is a host for Git repositories. At some point, it is helpful to place your Git repository in a shared location as both a backup and a place where others can collaborate with you on your code. As a Git host, Git provides all the features of Git in addition to a few extra useful services.
On GitHub.com, projects, or repositories, are stored on remote GitHub servers. If you save all your code on GitHub.com and your computer crashes, you can still access it.
Here is a list of some core Git features that GitHub supports:
Repository:
Each repository contains all the files and folders related to your project and gives you control of permissions and collaborators’ interaction with your code.
Clone:
When you want to make changes to your code, you will often want to create a copy, or
clone
,
of the project on your local computer. The cloned project is still tightly connected with the version on GitHub.com; it’s just your local copy.
Fork:
Forking
a project is when you create your own copy of the entire project. When you
fork
a project, GitHub.com creates a new repository with your copy of all the files. You can still suggest changes back to the original copy, but you can also take your version and go in a new direction.
Branches:
GitHub.com supports branching and even provides a useful tool —
pull requests
— to compare the diff between branches and
merge
branches.
Commits:
GitHub.com tracks all the
commits
that you push to its servers and gives you an easy interface for browsing the code at different branches and different commits.
GitHub.com offers unlimited free public and private repositories for individuals. Free private accounts are limited to three collaborators. You can sign up for a paid account to have unlimited collaborators and some Pro features.
Public means that anyone can see your code, clone your code, and therefore use your code. GitHub is a huge supporter of open source software (OSS) and therefore encourages public, shared code. Open source software is more than just public, shared code (see Part 5). Because every line of code can be traced to an author, you still get credit for what you've written, but the goal is to keep the code available for anyone to use, extend, and explore.
The following steps guide you through signing up for a free, individual GitHub.com account:
Go to GitHub.com and fill out the Sign Up form.
Choose the plan you want.
For the purpose of this book, you can use the Free plan. You can always upgrade to a paid plan later if you decide you want to have more than three collaborators for your private repository and other pro GitHub features.
Complete the brief survey.
This survey helps GitHub understand who is using the software and helps them support workflows specific to their users.
You’re now at the home page, shown in Figure 1-2.
FIGURE 1-2: The GitHub.com home page when you’re logged in.
As you become a more experienced coder, you may want to reference your GitHub.com profile on your resume and job applications. More and more companies care more about your portfolio than a list of degrees or awards. For example, GitHub doesn’t require you to provide information on your education as part of the hiring process and instead asks for a link to your GitHub.com profile and/or portfolio.
To complete your GitHub.com profile:
Click the avatar icon in the top right corner and choose Your Profile.
Click Edit Profile on the page that appears.
Fill out the form on the Personal Settings page, shown in
Figure
1-3
.
Click Update profile when you’re finished.
FIGURE 1-3: The Personal Settings page.
On the Personal Settings page, you can also adjust a number of different settings to continue personalizing your account.
In Account settings, you can change your password, change your username, or delete your account (see Figure 1-4).
FIGURE 1-4: Account settings.
Changing your username may cause unintended side effects, so it typically isn’t recommended. Just make sure that after you change your username that anything that you need to continue working still does. Follow links, test code, and run your applications again.
GitHub allows you to link multiple email addresses to your account. Notice that you can add email addresses, keep your email address private, and even block Git commands that may expose your email address (see Figure 1-5).
FIGURE 1-5: The Email settings.
Notifications can get really overwhelming. Though you can choose your level of granularity for receiving notifications per repository, this page creates your default preferences for notifications (see Figure 1-6).
FIGURE 1-6: The Notifications settings.
