初识 GitHub
2015-08-18 21:43
323 查看
主要参考官方的bootcamp https://help.github.com/articles/set-up-git/
Set Up Git
在GitHub的心脏是一个开源的版本控制系统(VCS)称为Git的。 Git是负责一切GitHub上有关这发生在本地计算机上。如果你不喜欢使用命令行,现在,GitHub上,您可以完成许多Git的相关操作,而无需使用命令行,其中包括:
Creating
a repository
Forking
a repository
Being
social
Setting up Git
1 下载; Download and install the latest version of GitHubfor Windows. This will automatically install Gitand keep it up-to-date for you.
2 打开Git Shell; On your computer, open the Git
Shell application.
3 git你的名字;Tell Git your name so your commits will be properly labeled. Type everything after
the
$here:
, you should choose to create a new branch for your commit and then creategit config --global user.name "YOUR NAME"
4 git你的e-mail;Tell Git the email address that will be associated with your Git commits. The
email you specify should be the same one found in your email
settings. To keep your email address hidden, see "Keeping
your email address private".
[code]git config --global user.email "YOUR EMAIL ADDRESS"两种方式认证git;https/SSH
Next steps: Authenticating with GitHub from Git
When you connect to a GitHub repository from Git, you'll need to authenticate with GitHub using either HTTPS or SSH.If you clone
Connecting
over HTTPS (recommended)
with HTTPS, you can cache
your GitHub password in Git using a credential helper.If you clone
Connecting
over SSH
with SSH, you must generate
SSH keys on each computer you use to push or pull from GitHub.1 点击创建 In the upper-right corner of any page, click , and then click New
Create a new repository on GitHub
repository.
2 Create a short, memorable name for your repository. For example, "hello-world".
3 Optionally, add a description of your repository. For example, "My first repository on GitHub."
4 Choose between creating a public or private repository.
公共库是入门的绝佳选择!他们看到在GitHub上的任何用户,这样你就可以从一个协作社区受益。
私人库需要更多的设置。他们只提供给你,仓库主人,以及您选择与之共享的任何合作者。
Public repositories are a great choice for getting started! They're visible
to any user on GitHub, so you can benefit from a collaborative community.
Private repositories require a little more setup. They're only available
to you, the repository owner, as well as any collaborators you
choose to share with. Private repositories are only available for paid accounts. For more information, see "What
plan should I choose?.
5 Select Initialize
this repository with a README.
6 Click Create
repository.
Congratulations! You've successfully created your first repository, and initialized it with a README file.A commit is
Commit your first change
like a snapshot of all the files in your project at a particular point in time.
When you created your new repository, you initialized it with a README file. README files
are a great place to describe your project in more detail, or add some documentation such as how to install or use your project. The contents of your README file
are automatically shown on the front page of your repository.
Let's commit a change to the README file.
1 打开 In your repository's list of files, click README.md.
2 Above the file's content, click .
3 On
the Edit file tab
, type some information about yourself.
4 Above the new content, click Preview changes.
5 Review the changes you made to the file. You'll see the new content in green.
6 At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file.
7 Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is [code]master
a pull request.
Click Propose file change.
fork就是一个仓库的副本。分叉存储库可以让你自由地尝试改变,而不会影响原来的项目。
最常见的是,叉是用来或者提出修改别人的项目,或者用别人的项目为起点,为您自己的想法。
Fork an example repository
Forking a repository is a simple two-step process. We've created a repository for you to practice with!1 On GitHub, navigate to the octocat/Spoon-Knife repository.
2 In the top-right corner of the page, click Fork.
That's it! Now, you have a fork of
the original octocat/Spoon-Knife repository.
Keep
your fork synced
You might fork a project in order to propose changes to the upstream, or original, repository.In this case, it's good practice to regularly sync your fork with the upstream repository. To do this, you'll need to use Git on the command line. You can practice setting the upstream repository using the same octocat/Spoon-Knife repository
you just forked!
Step
1: Set Up Git
If you haven't yet, you should first setup Git. Don't forget to set
up authentication to GitHub from Git as well.
Step
2: Create a local clone of your fork
Right now, you have a fork of the Spoon-Knife repository, but you don't have the files in that repository on your computer. Let's create a clone ofyour fork locally on your computer.
1 On GitHub, navigate to your fork of the Spoon-Knife repository.
2 复制地址 In the right sidebar of your fork's repository page, click to copy the clone URL for your fork.
3 Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
4 Type
git clone, and then paste the URL you copied in Step 2. It will look like this, with your GitHub username instead of
YOUR-USERNAME:
git clone https://github.com/YOUR-USERNAME/Spoon-Knife
5 Press Enter. Your local clone will be created.with no other text.git clone https://github.com/YOUR-USERNAME/Spoon-Knife# Cloning into `Spoon-Knife`...# remote: Counting objects: 10, done.# remote: Compressing objects: 100% (8/8), done.# remove: Total 10 (delta 1), reused 10 (delta 1)# Unpacking objects: 100% (10/10), done.
Now, you have a local copy of your fork of the Spoon-Knife repository!When you fork a project in order to propose changes to the original repository, you can configure Git to pull changes from the original, or upstream,
Step
3: Configure Git to sync your fork with the original Spoon-Knife repository
repository into the local clone of your fork.
1 On GitHub, navigate to the octocat/Spoon-Knife repository.
2 In the right sidebar of the repository page, click to copy the clone URL for the repository.
3 Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
4 Change directories to the location of the fork you cloned in Step
2: Create a local clone of your fork.
To go to your home directory, type just [code]cd
To list the files and folders in your current directory, typels.
To go into one of your listed directories, typecd your_listed_directory.
To go up one directory, typecd ...
记住进入刚才的目录下面
5 Typegit remote -vand press Enter. You'll
see the current configured remote repository for your fork., and then paste the URL you copied in Step 2 and pressEnter.git remote -v# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
6 Type [code]git remote add upstream
It will look like this:git remote add upstream https://github.com/octocat/Spoon-Knife.git
7 To verify the new upstream repository you've specified for your fork, typegit remote -vagain. You should see the URL for your fork asorigin, and the URL for the original repository asupstream.
[code]git remote -v <span style="font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit;"># origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)</span>
Now, you can keep your fork synced with the upstream repository with a few Git commands. For more information, see "Syncing
a fork."When you follow someone on GitHub, you'll get notifications on your dashboard about their activity.
Follow People
Once you are on one of their pages, click the "follow" button.At some point you may want to stay up-to-date with a specific project. When you're on a project page, you can click the Watch button
Watch
A Project
at the top of the page.
When the owner updates the project, you'll see what happened in your dashboard.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:
More
Things You Can Do
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. Each repository has an Issues section to help you keep track of these problems.
Organizations
Have you found yourself wishing you could collaborate with multiple people 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.
Explore
Discover interesting projects in the Explore
GitHub and Trending
page sections. You can then star projects that you find interesting and want to come back to later—just visit your stars
page to see all your starred projects.
第一次学习使用GitHub,很多都不会,请哪位大神多多提点指教啊。谢谢啦
相关文章推荐
- java字符串
- ASP.NET查找路由表RouteTable中路由名等信息的方法
- IOT command (based on sip)client API设计 for java
- Python学习(一)初识
- Delphi XE7 安装
- Java中Map的简单使用
- Marlin固件之二:源代码详解与移植
- Java深度历险(八)Java I/O
- PB动态游标代码段
- 截断WM_SYSCOMMAND的SC_CLOSE命令(VC与Delphi双版本)
- JAVA中利用不规则二维数组输出杨辉三角形
- Java的基本程序设计结构(一)
- MyEclipse配置Hibernate/MyEclipse反向工程从数据表生成POJO和对象关系映射文件(以及HibernateSessionFactory)
- vijos - P1543极值问题(斐波那契数列 + 公式推导 + python)
- C# string[,]与string[][]的区别
- python 数据类型 序列——列表
- C语言实现直接插入排序,冒泡排序以及二分查找(巩固理解记忆)
- Eclipse快捷键
- Moist (cin,getline的区别)
- Python StringIO与cStringIO