If you've found yourself on this page, we're assuming you're brand new to Git and GitHub. This guide will walk you through the basics and explain a little bit about how everything works along the way.
Download and Install Git
At the heart of GitHub is an open source version control system (VCS) called Git*. Created by the same team that created Linux, Git is responsible for everything GitHub related that happens locally on your computer.
*If you don't already know what Git is, take a crash course.
Download and install the latest version of Git.
Good to know: Git won't add an icon anywhere, it's not that sort of application.
Set Up Git
Now that you have Git installed, it's time to configure your settings. To do this you need to open an app called Terminal.
Username
First you need to tell git your name, so that it can properly label the commits you make.
git config --global user.name "Your Name Here" # Sets the default name for git to use when you commit
Git saves your email address into the commits you make. We use the email address to associate your commits with your GitHub account.
git config --global user.email "your_email@example.com" # Sets the default email for git to use when you commit
Your email address for Git should be the same one associated with your GitHub account. If it is not, see this guide for help adding additional emails to your GitHub account. If you want to keep your email address hidden, this guide may be useful to you.
Password caching
The last option we need to set will tell git that you don't want to type your username and password every time you talk to a remote server.
Good to know: You need git 1.7.10 or newer to use the credential helper
To use this option, you need to turn on the credential helper so that git will save your password in memory for some time:
git config --global credential.helper cache # Set git to use the credential memory cache
By default git will cache your password for 15 minutes. You can change this if you like.
git config --global credential.helper 'cache --timeout=3600' # Set the cache to timeout after 1 hour (setting is in seconds)
Good to know: The credential helper only works when you clone an HTTPS repository URL. If you use the SSH repository URL instead, SSH keys are used for authentication. This guide offers help generating and using an SSH key pair.
Make a new repository on GitHub
Every time you make a commit with Git, it is stored in a repository (a.k.a. "repo"). To put your project up on GitHub, you'll need to have a GitHub repository for it to live in.
Click New Repository.
Fill out the information on this page. When you're done, click "Create Repository."
Congratulations! You have successfully created your first repository!
Create a README for your repository
While a README isn't a required part of a GitHub repository, it is a very good idea to have one. READMEs are a great place to describe your project or add some documentation such as how to install or use your project. You might want to include contact information - if your project becomes popular people will want to help you out.
Step 1: Create the README file
In the prompt, type the following code:
mkdir ~/Hello-World # Creates a directory for your project called "Hello-World" in your user directory cd ~/Hello-World # Changes the current working directory to your newly created directory git init # Sets up the necessary Git files # Initialized empty Git repository in /Users/you/Hello-World/.git/ touch README # Creates a file called "README" in your Hello-World directory
Open the new README file found in your Hello-World directory in a text editor and add the text "Hello World!" When you are finished, save and close the file.
Step 2: Commit your README
Now that you have your README set up, it's time to commit it. A commit is essentially a snapshot of all the files in your project at a particular point in time. In the prompt, type the following code:
More about commits
git add README # Stages your README file, adding it to the list of files to be committed git commit -m 'first commit' # Commits your files, adding the message "first commit"
Step 3: Push your commit
So far everything you've done has been in your local repository, meaning you still haven't done anything on GitHub yet. To connect your local repository to your GitHub account, you will need to set a remote for your repository and push your commits to it:
More about remotes
git remote add origin https://github.com/username/Hello-World.git # Creates a remote named "origin" pointing at your GitHub repository git push origin master # Sends your commits in the "master" branch to GitHub
Now if you look at your repository on GitHub, you will see your README has been added to it.
Fork A Repo
If you've found yourself on this page, we're assuming you're brand new to Git and GitHub. This guide will walk you through the basics and explain a little bit about how everything works along the way.
Contributing to a project
At some point you may find yourself wanting to contribute to someone else's project, or would like to use someone's project as the starting point for your own. This is known as "forking." For this tutorial, we'll be using the Spoon-Knife project.
Step 1: Fork the "Spoon-Knife" repository
To fork this project, click the "Fork" button.
Step 2: Clone your fork
You've successfully forked the Spoon-Knife repository, but so far it only exists on GitHub. To be able to work on the project, you will need to clone it to your local machine.
Run the following code:
git clone https://github.com/username/Spoon-Knife.git # Clones your fork of the repository into the current directory in terminal
Step 3: Configure remotes
When a repository is cloned, it has a default remote called origin
that points to your fork on GitHub, not the original repository it was forked from. To keep track of the original repository, you need to add another remote named upstream
:
More about remotes
cd Spoon-Knife # Changes the active directory in the prompt to the newly cloned "Spoon-Knife" directory git remote add upstream https://github.com/octocat/Spoon-Knife.git # Assigns the original repository to a remote called "upstream" git fetch upstream # Pulls in changes not present in your local repository, without modifying your files
More Things You Can Do
You've successfully forked a repository, but get a load of these other cool things you can do:
Push commits
Once you've made some commits to a forked repository and want to push it to your forked project, you do it the same way you would with a regular repository:
More about commits
git push origin master # Pushes commits to your remote repository stored on GitHub
Pull in upstream changes
If the original repository you forked your project from gets updated, you can add those updates to your fork by running the following code:
git fetch upstream # Fetches any new changes from the original repository git merge upstream/master # Merges any changes fetched into your working files
Create branches
Branching allows you to build new features or test out ideas without putting your main project at risk. In git, branch is a sort of bookmark that references the last commit made in the branch. This makes branches very small and easy to work with.
Pull requests
If you are hoping to contribute back to the original fork, you can send the original author a pull request.
Unwatch the main repository
When you fork a particularly popular repository, you may find yourself with a lot of unwanted updates about it. To unsubscribe from updates to the main repository, click the "Unwatch" button on the main repository.
Delete your fork
At some point you may decide that you want to delete your fork. To delete a fork, just follow the same steps as you would to delete a regular repository.
Be Social
If you've found yourself on this page, we're assuming you're brand new to Git and GitHub. This guide will walk you through the basics and explain a little bit about how everything works along the way.
Follow A Friend
One of the great features on GitHub is the ability to see what other people are working on and who they are connecting with. When you follow someone, you will get notifications on your dashboard about their GitHub activity.
Step 1: Pick a friend.
Why not follow one of these cool people?
Who are these fine fellows? Why, they're founders of GitHub and their pet tanuki, of course!
Step 2: Follow that friend (in a non-creepy way)
Once you are on one of their pages, click the "follow" button.
Congratulations! You are now following a friend.
Watch A Project
At some point you may want to stay up-to-date with a specific project. We've made this easy to do.
Watch a project
Our friend the Octocat has a project called Hello World that we'd like to watch.
Once you are on the project page, you will notice there is a "watch" button at the top of the page. Click on it.
Congratulations! You are now watching the Hello World project. If the Octocat updates it, you will see what happened in your dashboard.
More Things You Can Do
You've done some of the most basic social interaction GitHub has to offer, but don't stop there! Check out these other social features:
Pull Requests
You may find yourself wanting to contribute to someone else's project, whether to add features or to fix bugs. After making changes, you can let the original author know about them by sending a pull request.
Issues
When you are collaborating on a project with someone, you sometimes come across problems that need to be fixed. To help you keep track of these problems, each GitHub repository has a section called Issues. For an example, check out the issues for the Spoon-Knife repository.
Organizations
Have you found yourself wishing you could collaborate with multiple developers on one project? You can manage everyone with Organizations! With an organization you can establish teams with special permissions, have a public organization profile, and keep track of activity within the organization.
来源: https://help.github.com/articles/be-social
相关推荐
### Java基础教程(初级) #### 一、Java作为一门编程语言的价值 Java作为一种高级编程语言,在计算机科学领域占据着举足轻重的地位。对于初学者而言,了解Java的基础概念及其实现逻辑至关重要。正如该教程所提到的...
- **特点**:由Jason Barnabe创建,该平台上存储了大量的脚本资源,并且支持从GitHub中同步脚本,活跃度高。 2. **OpenUserJS** - **网址**:[https://openuserjs.org/](https://openuserjs.org/) - **特点**:...
9. **多线程**:Thread类,Runnable接口,同步机制(synchronized关键字,wait(),notify())。 10. **设计模式**:可能介绍一些基础设计模式,如单例模式、工厂模式、观察者模式等。 11. **JDK工具类**:如Math类,...
【标题】"level1-module4-abhik026:GitHub Classroom创建的level1-module4-abhik026" 指的是一项基于GitHub Classroom的学习项目,这通常用于教育环境中,让学生和教师进行协作。这个项目的命名结构表明它属于一系列...
在本项目"level1-module1-demiansebat"中,我们关注的是GitHub Classroom创建的一个学习资源,主要用于初级级别的Java编程教学。这个项目很可能是为了帮助初学者理解和掌握Java语言的基础概念,逐步构建编程思维和...
Git的高级用法包括工作流策略,如Git Flow或GitHub Flow,它们规定了如何有效地管理分支和发布流程。此外,你还需掌握重置(`git reset`)、回退(`git revert`)和变基(`git rebase`)等操作,这些在解决冲突或...
- **Android基础入门**:掌握Android SDK的安装与配置,了解Android Studio的基本使用方法。 - **Android用户界面**:熟练使用各种UI组件(如TextView、Button等),了解自定义视图的原理。 - **Android基本组件*...
然而,由于缺乏详细信息,具体的使用方法和功能还需用户自行研究或查阅库的官方文档。在使用过程中,遇到问题时,可以参考社区讨论、GitHub上的源码,或者直接向库的维护者提问,以便更好地理解和利用这个工具。
二、库的使用方法 1. 引入库:首先,你需要在项目的build.gradle文件中添加对sliding-layer-lib的依赖,然后同步项目以获取库的资源。 2. 布局集成:在布局XML文件中,使用<com.github.mik3y.slidinglayer....
本文将详细介绍EasyHttp的特点、使用方法以及如何将其集成到你的Android项目中。 ### EasyHttp简介 EasyHttp的目标是提供一个简洁、易于理解和使用的网络请求框架。它的主要特点包括: 1. **简单易用**:EasyHttp...
为了帮助开发者快速上手,Maratis-4-master可能包含了一系列示例项目和教程,涵盖了基础到高级的游戏开发概念,如光照、粒子系统、AI行为和网络同步等。这些示例不仅可以帮助理解引擎的用法,还可以作为自定义项目的...
- README文件:包含项目简介、安装指南、使用方法和贡献方式等信息,方便他人理解和参与项目。 7. **错误与调试** - 错误类型:理解Python中的语法错误、运行时错误和逻辑错误,学会识别和定位问题。 - 调试技巧...
1. **README** 文件:这是一个常见的文档,用于介绍项目的基本信息、安装指南和使用方法。 2. **src** 目录:源代码通常存放在这里,可能包含多个子目录和以`.c`, `.cpp`, `.java`, `.py`等为扩展名的源代码文件。 3...
线程间的通信和同步,如synchronized关键字、wait()、notify()方法,也是Java并发编程中的重点。 网络编程是Java的另一个重要领域,Java的Socket编程允许我们创建客户端和服务器应用。了解TCP/IP协议,并能使用...
【压缩包子文件的文件名称列表】"java-lab-code-master"通常表示这是一个Git仓库的主分支,其中可能包含README文件(介绍项目的目的、使用方法和贡献指南)、源代码文件夹(src)、测试代码(test)、构建脚本(如...
10. **Maven/Gradle**:项目构建工具如Maven或Gradle用于管理依赖、构建流程,理解其配置和使用方法是必要的。 11. **单元测试**:JUnit是Java常用的单元测试框架,开发者应学会编写测试用例,确保代码的正确性。 ...
不过,我们可以推测这可能是一个初级或中级水平的编程练习,旨在帮助学习者熟悉Java语言的基础概念和编程技巧。 基于标签“Java”,我们可以深入讨论Java相关的知识点: 1. **Java基础**: 包括变量、数据类型、...
6. **多线程**:理解并发编程概念,使用Thread和Runnable,以及同步机制如synchronized关键字和Lock接口。 7. **异常处理**:学习如何正确地捕获和处理运行时错误,提高程序的健壮性。 8. **JDBC**:如果涉及到...
Java是一种广泛使用的面向对象的编程语言,以其跨平台、高性能和丰富的类库而著名。"demos: 可以玩的 Java 东西"这个标题暗示我们这里包含的是一个Java演示项目或者一系列示例代码,目的是为了让用户通过实践来学习...