【转】Github轻松上手2-如何使用命令行建立和管理repo

转自:http://blog.sina.com.cn/s/blog_4b55f6860100zzhd.htmlhtml

 

若是你对这种怀旧的方式很感冒,不妨参考这里:git

http://help.github.com/create-a-repo/github

 

这里只是稍微简单介绍一下:服务器

 

1.建立一个新的repo编辑器

在网页中点击New Repositoryurl

Github轻松上手2-如何使用命令行建立和管理repo

填写下面的信息,而后点击”Create Repository”命令行

 
Github轻松上手2-如何使用命令行建立和管理repo

 

2.建立一个README3d

 

通常状况下都建议建立一个READMEhtm

在Terminal中输入美圆符号后面的命令blog

 

$ 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/your_user_directory/Hello-World/.git/

$ touch README

 

而后使用文本编辑器打开repo里面的Hello-World文件夹的README文件。而后随便输入几句话,编辑完成后保存并关闭。

 

3.commit这个README

 

正如第1部分的工做原理所讲,commit实际上是建立某个特定时点的项目内全部文件的快照。

使用下面的命令:

 

$ git add README

做用:Stages your README file, adding it to the list of files to be committed

$ git commit -m 'first commit'

 

 

一直到这一步,咱们都仍是在本地操做。

 

4.远程建立一个repo(在GitHub服务器中),并push刚才的commit

 

$ git remote add origin git@github.com:username/Hello-World.git

做用:Sets the origin for the Hello-World repo

$ git push -u origin master

 

 

如今你的repository已经在GitHub中建立成功了。

 

 

Github轻松上手2-如何使用命令行建立和管理repo

相关文章
相关标签/搜索