您的位置:首页 > 编程语言

Mac之Git/GitHub使用(2)——Create A Repo

2014-04-07 00:51 375 查看
2014-04-06 wcdj

摘要:前文《Mac之Git/GitHub使用(1)——Set
up Git 》介绍了如何在Mac上通过git关联和使用GitHub的方法。本文继续介绍下Create A Repo的方法。

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.

如何把本地的git repo和GitHub repo联系起来呢?

(1) 在GitHub的个人账户上可以创建一个repo。



例如,创建一个nodejs-code的repo,注意我们没有选择创建默认的README。



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.



README用于介绍创建的repo的相关信息,更多关于README的高级用法,可以参考:https://github.com/github/markup。点击Create repository按钮后,可以看到如下的操作提示,主要有以下几个步骤:

Step 1: Create the README file

Step 2: Commit your README

Step 3: Push your commit

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.



注意:在GitHub上不要上传过大的文件,包括一些库、二进制文件、压缩包等。

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.

到目前为止,我们所有的改动都是发生在本地的,所以需要将本地的改动commit到远程的GitHub上。





回到我们刚创建好的repo中,我们根据提示执行命令:



修改成下面的方法就可以向远程的GitHub commit文件(README.md)了。其中,使用https://github.com/gerryyang/nodejs-code的访问方式只能在浏览器里操作,所以改成ssh的后台登陆方式来与远程的GitHub进行交互了,关于如何Add SSH Key,第一篇文章里有介绍。



Now if you look at your repository on GitHub, you will see your README has been added to it.

提交成功后,现在就可以在GitHub上看到我们刚提交的README.md文件了。



Celebrate

Congratulations! You have now created a repository on GitHub, created a README, committed it, and pushed it to GitHub. What do you want to do next?

Set Up Git
Create A Repository
Fork A Repository
Be Social

参考

[1] https://help.github.com/articles/create-a-repo
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: