It’s 2013, and there’s no way around it: you need to learn how to use GitHub.2

Why? Because it’s a social network that has completely changed the way we work. Having started as a developer’s collaborative platform, GitHub is now the largest online storage space of collaborative works that exists in the world. Whether you’re interested in participating in this global mind meld or in researching this massive file dump of human knowledge, you need to be here.

See also: GitHub For Beginners: Commit, Push And Go

Simply by being a member, you can brush elbows with the likes of Google and Facebook. Before GitHub existed, major companies created their knowledge mainly in private. But when you access their GitHub accounts, you’re free to download, study, and build upon anything they add to the network. So what are you waiting for?

Looking For GitHub Answers

As embarrassing as it is to admit, this tutorial came into being because all of the “GitHub for Beginners” articles I read were way over my head. That’s probably because I don’t have a strong programming background, like most GitHub users. I couldn’t identify with the way most tutorials suggest using GitHub, as a showcase for my programming work.

See also: Github’s Tom Preston-Werner: How We Went Mainstream

What you might not know is that there are plenty of reasons to use GitHub if you’re not a programmer. According to GitHub’s educational videos, any knowledge worker can benefit, with “knowledge worker” defined as most any profession that makes use of a computer.

If you’ve given up on understanding how to use GitHub, this article is for you.17

One of the main misconceptions about GitHub is that it’s a development tool, as much a part of coding as computer languages and compilers. However, GitHub itself isn’t much more than a social network like Facebook or Flickr. You build a profile, upload projects to share and connect with other users by “following” their accounts. And while many users store programs and code projects, there’s nothing preventing you from keeping text documents or other file types in your project folders to show off.


The author's GitHub page.

You may already have a dozen other social media accounts, but here’s why you should be on GitHub anyway: it’s got the best Terms of Service agreement out of the bunch. If you check out Section F of the terms, you’ll see that GitHub does everything in its power to ensure that you retain total ownership of any projects you upload to the site:

“We claim no intellectual property rights over the material you provide to the Service. Your profile and materials uploaded remain yours.”

What’s more, you can actually use GitHub without knowing ANY code at all. You don’t really need a tutorial to sign up and click around. But I do think that there’s merit to learning things the hard way first, by which I mean, with plain old coding in Git. After all, GitHub just happens to be one of the most effortless graphical interfaces for the Git programming language.

What Is Git?

Thank famed software developer Linus Torvalds for Git, the software that runs at the heart of GitHub. (And while you’re at it, go ahead thank him for the Linux operating system, too.) Git is version control software, which means it manages changes to a project without overwriting any part of that project. And it’s not going away anytime soon, particularly since Torvalds and his fellow kernel developers employ Git to help develop the core kernel for Linux.

Why use something like Git? Say you and a coworker are both updating pages on the same website. You make your changes, save them, and upload them back to the website. So far, so good. The problem comes when your coworker is working on the same page as you at the same time. One of you is about to have your work overwritten and erased.

A version control application like Git keeps that from happening. You and your coworker can each upload your revisions to the same page, and Git will save two copies. Later, you can merge your changes together without losing any work along the way. You can even revert to an earlier version at any time, because Git keeps a “snapshot” of every change ever made.

The problem with Git is that it’s so ancient that we have to use the command line—or Terminal if you’re a Mac user—in order to access it, typing in snippets of code like ‘90s hackers. This can be a difficult proposition for modern computer users. That’s where GitHub comes in.


The author's Terminal screen on a Mac.

GitHub makes Git easier to use in two ways. First, if you download the GitHub software to your computer, it provides a visual interface to help you manage your version-controlled projects locally. Second, creating an account on GitHub.com brings your version-controlled projects to the Web, and ties in social network features for good measure.3

You can browse other GitHub users’ projects, and even download copies for yourself to alter and learn from. Other users can do the same with your public projects, and even spot errors and suggest fixes. Either way, no data is lost because Git saves a “snapshot” of every change.

While it’s possible to use GitHub without learning Git, there’s a big difference between using and understanding. Before I figured out Git I could use GitHub, but I didn’t really understand why. In this tutorial, we’re going to learn to use Git on the command line.

Words People Use When They Talk About Git

In this tutorial, there are a few words I’m going to use repeatedly, none of which I’d heard before I started learning. Here’s the big ones:

Command Line: The computer program we use to input Git commands. On a Mac, it’s called Terminal. On a PC, it’s a non-native program that you download when you download Git for the first time (we’ll do that in the next section). In both cases, you type text-based commands, known as prompts, into the screen, instead of using a mouse.

Repository: A directory or storage space where your projects can live. Sometimes GitHub users shorten this to “repo.” It can be local to a folder on your computer, or it can be a storage space on GitHub or another online host. You can keep code files, text files, image files, you name it, inside a repository.

Version Control: Basically, the purpose Git was designed to serve. When you have a Microsoft Word file, you either overwrite every saved file with a new save, or you save multiple versions. With Git, you don’t have to. It keeps “snapshots” of every point in time in the project’s history, so you can never lose or overwrite it.

Commit: This is the command that gives Git its power. When you commit, you are taking a “snapshot” of your repository at that point in time, giving you a checkpoint to which you can reevaluate or restore your project to any previous state.

Branch: How do multiple people work on a project at the same time without Git getting them confused? Usually, they “branch off” of the main project with their own versions full of changes they themselves have made. After they’re done, it’s time to “merge” that branch back with the “master,” the main directory of the project.

Git-Specific Commands

Since Git was designed with a big project like Linux in mind, there are a lot of Git commands. However, to use the basics of Git, you’ll only need to know a few terms. They all begin the same way, with the word “git.”

git init: Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.

git config: Short for “configure,” this is most useful when you’re setting up Git for the first time.

git help: Forgot a command? Type this into the command line to bring up the 21 most common git commands. You can also be more specific and type “git help i4nit” or another term to figure out how to use and configure a specific git command.

git status: Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.

git add: This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.

git commit: Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.” The -m indicates that the following section of the command should be read as a message.

git branch: Working with multiple collaborators and want to make changes on your own? This command will let you build a new branch, or timeline of commits, of changes and file additions that are completely your own. Your title goes after the command. If you wanted a new branch called “cats,” you’d type git branch cats.

git checkout: Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check. You can use this command as git checkout master to look at the master branch, or git checkout cats to look at another branch.

git merge: When you’re done working on a branch, you can merge your changes back to the master branch, which is visible to all collaborators. git merge cats would take all the changes you made to the “cats” branch and add them to the master.

git push: If you’re working on your local computer, and want your commits to be visible online on GitHub as well, you “push” the changes up to GitHub with this command.

git pull: If you’re working on your local computer and want the most up-to-date version of your repository to work with, you “pull” the changes down from GitHub with this command.

Setting Up GitHub And Git For The First Time


GitHub's signup page.

First, you’ll need to sign up for an account on GitHub.com. It’s as simple as signing up for any other social network. Keep the email you picked handy; we’ll be referencing it again soon.

You could stop there and GitHub would work fine. But if you want to work on your project on your local computer, you need to have Git installed. In fact, GitHub won’t work on your local computer if you don’t install Git. Install Git for Windows, Mac or Linux as needed.


http://git-scm.com/, where you download Git.

Now it’s time to go over to the command line. On Windows, that means starting the Git Bash app you just installed, and on OS X, it’s regular old Terminal. It’s time to introduce yourself to Git. Type in the following code:

git config --global user.name "Your Name Here"

Of course, you’ll need to replace “Your Name Here” with your own name in quotations. It can be your legal name, your online handle, anything. Git doesn’t care, it just needs to know to whom to credit commits and future projects.

Next, tell it your email and make sure it’s the same email you used when you signed up for a GitHub.com account just a moment ago. Do it like this:

git config --global user.email "your_email@youremail.com"

That’s all you need to do to get started using Git on your computer. However, since you did set up a GitHub.com account, it’s likely you don’t just want to manage your project locally, but also online. If you want you can also set up Git so it doesn’t ask you to log in to your GitHub.com account every time you want to talk to it. For the purposes of this tutorial, it isn’t a big deal since we’ll only be talking to it once. The full tutorial to do this, however, is located on GitHub.


Baby's first Git commands.

Creating Your Online Repository

Now that you’re all set up, it’s time to create a place for your project to live. Both Git and GitHub refer to this as a repository, or “repo” for short, a digital directory or storage space where you can access your project, its files, and all the versions of its files that Git saves.

Go back to GitHub.com and click the tiny book icon next to your username. Or, go to the new repository page if all the icons look the same. Give your repository a short, memorable name. Go ahead and make it public just for kicks; why hide your attempt to learn GitHub?


Creating a new repository on GitHub.

Don’t worry about clicking the checkbox next to “Initialize this repository with a README.” A Readme file is usually a text file that explains a bit about the project. But we can make our own Readme file locally for practice.

Click the green “Create Repository” button and you’re set. You now have an online space for your project to live in.

Creating Your Local Repository

So we just made a space for your project to live online, but that’s not where you’ll be working on it. The bulk of your work is going to be done on your computer. So we need to actually mirror that repository we just made as a local directory.

This—where we do some heavy command line typing—is the part of every Git tutorial that really trips me up, so I’m going to go tediously, intelligence-insultingly slow.

First type:

mkdir ~/MyProject

mkdir is short for make directory. It’s not actually a Git command, but a general navigational command from the time before visual computer interfaces. The ~/ ensures that we’re building the repository at the top level of your computer’s file structure, instead of stuck inside some other directory that would be hard to find later. Actually, if you type ~/ into your browser window, it’ll bring up your local computer’s top level directory. For me, using Chrome on a Mac, it displays my Users folder.

Also, notice that I called it MyProject, the very same name I called my GitHub repository that we made earlier. Keep your name consistent, too.

Next, type:

cd ~/MyProject

cd stands for change directory, and it’s also a navigational command. We just made a directory, and now we want to switch over to that directory and go inside it. Once we type this command, we are transported inside MyProject.

Now we’re finally using a Git command. For your next line, type:

git init

You know you’re using a Git command because it always begins with git. init stands for “initialize.” Remember how the previous two commands we typed were general command-line terms? When we type this code in, it tells the computer to recognize this directory as a local Git repository. If you open up the folder, it won’t look any different, because this new Git directory is a hidden file inside the dedicated repository.


Creating a local Git repository in three steps.

However, your computer now realizes this directory is Git-ready, and you can start inputting Git commands. Now you’ve got both an online and a local repo for your project to live inside. In Part 2 of this series, you will learn how to make your first commit to local and GitHub repositories, and learn about more great GitHub resources.

(See also: GitHub For Beginners: Commit, Push And Go)

转载于:https://www.cnblogs.com/tl2f/p/8261511.html

GitHub For Beginners: Don’t Get Scared, Get Started相关推荐

  1. c mysql 返回字符串长度_objective-c中字符串长度计算

    我们知道,在c语言中,使用sizeof ()计算在内存中占用的字节数, 引用string.h后,使用strlen()计算字符串的长度(不包含\0). 而在object-c中, "length ...

  2. 微软推出Python入门课,登上GitHub趋势榜第一(附视频)

    来源:新智元 本文约900字,建议阅读10分钟. 本文带你看视频轻松学习python课程! [ 导读 ] 微软针对 Python 初学者,推出了一套免费的教程视频.这套课程最大的特定是轻松简洁,一上线 ...

  3. 如何在GitHub上重命名存储库?

    本文翻译自:How do I rename a repository on GitHub? I wanted to rename one of my repositories on GitHub, b ...

  4. 刷个B站的功夫就能把Python学了,微软放出短视频入门课,资料登上GitHub热榜第一...

    乾明 发自 凹非寺  量子位 报道 | 公众号 QbitAI 微软,正在用力拥抱Python. 继Windows官方商店中加入了Python 3.7,支持一键安装Python之后. 这一不断为开源世界 ...

  5. 微软推出Python入门课,登上GitHub趋势榜第一

    [新智元导读]微软针对 Python 初学者,推出了一套免费的教程视频.这套课程最大的特定是轻松简洁,一上线就很受欢迎,5天视频播放量超25万,更一度登上GitHub趋势榜第一名. 最近,微软针对 P ...

  6. github 6月开源项目_我的开源项目如何在短短5天内在GitHub上赢得6,000颗星

    github 6月开源项目 Last month I launched two open source projects on GitHub. A few days later, my Front-E ...

  7. 程序员github头像_给新程序员的5个GitHub技巧

    程序员github头像 by Alyson La 由Alyson La 给新程序员的5个GitHub技巧 (5 GitHub tips for new coders) This October I c ...

  8. 【github】机器学习(Machine Learning)深度学习(Deep Learning)资料

    转自:https://github.com/ty4z2008/Qix/blob/master/dl.md# <Brief History of Machine Learning> 介绍:这 ...

  9. 《Reverse Engineering for Beginners》读书笔记(一):前言

    研究逆向工程<RE for beginners>一定是本好书,我只能去找英文看,为什么不看中文的原因就不解释了.这本书英文有1000多页,工程量有点大! 看看这些目录,真心佩服老外写的书, ...

最新文章

  1. an初始java运行环境错误_【环境问题】STS(eclipse)启动出现错误提示:an error hava occured,see the log......
  2. 电子商务就是计算机技术在传统商务中的应用,数据计算机论文,关于计算机Web数据其在电子商务中的应用相关参考文献资料-免费论文范文...
  3. 高考成绩查询接口(转)
  4. mysql用户创建,及授权
  5. c++ string后面会添加‘\0‘
  6. img写入工具_硬盘有坏道,得用靠谱的修复工具,这3个不会让你失望
  7. 2019死磕java面试题_死磕 java同步系列之开篇
  8. ORACLE专有模式与共享模式
  9. Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci
  10. Python+tkinter实现简单的登录界面
  11. linux容器安装cmake
  12. Python手册(Python Basics)--Python基础
  13. Pygame教程(预备篇)
  14. 在Word中利用日历向导查农历
  15. 爱沙尼亚LHV银行矢志不渝,设立区…
  16. 中国正式进入 5G 商用元年!
  17. 数据分析——人力资源
  18. CSS——引入ico图标
  19. 首次接触大数据及其见解
  20. javaweb学习笔记(六)

热门文章

  1. php日志缓存,php – Symfony和Docker – 缓存和日志目录权...
  2. imx6 android6.0.1,mfgtool刷写i.MX6 android6.0版本失败
  3. C语言计算最大公约数和最小公倍数,C语言计算最大公约数和最小公倍数
  4. 多线程、多平台环境中的跟踪 - 使用 log4j 和 UNIX 命令来挖掘跟踪数据
  5. 华为AP3010DN-AGN升级为胖AP
  6. C#下拉列表绑定数据库的使用三层实现
  7. Spring Cloud 学习笔记(三) 之服务治理模块Spring Cloud 服务发现与消费
  8. Android-Gradle(四)
  9. [开源 .NET 跨平台 Crawler 数据采集 爬虫框架: DotnetSpider] [三] 配置式爬虫
  10. SEO基础问题:14.给图片添加alt标签的知识点