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

Mac 中 Github 配置和使用

2014-11-08 00:00 411 查看
摘要: Github是一个基于git的代码托管平台,作为开源代码库以及版本控制系统,Github目前拥有140多万开发者用户。随着越来越多的应用程序转移到了云上,Github已经成为了管理软件开发以及发现已有代码的首选方法。

1、下载安装 Git for Mac

注:以下代码$开头的为命令,#开头为注释

$ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit

$ git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit

# 在上述设置完毕后,可通过这两条命令查看自己的设置
$ git configuser.name
$ git config user.email


2、配置 Git

一、远程:
首先在 Github.com 上创建一个repository (例:Hello-World)

二、本地:
$ mkdir ~/Hello-World
# 在本地的~/目录下创建一个 git 仓库,目录创建在别处也可以
$ cd ~/Hello-World
# 切换至刚创建好的目录
$ git init
# 初始化一个本地的 git仓库,生成隐藏的.git目录

三、添加:
$ touch README
# Creates a file called "README" in your Hello-World directory
#(可以添加.txt .md .html等格式后缀),找到后可打开编辑。
$ git add README
# Stages your README file, adding it to the list of files to be committed
# 把README文件添加到仓库中
$ git commit -m 'first commit'
# Commits your files, adding the message "first commit"
# 执行提交说明

四、提交:
$ git remote add origin https://github.com/username/Hello-World.git # Creates a remote named "origin" pointing at your GitHub repository
# 使用https协议指定、连接远程仓库地址
$ git push origin master
# Sends your commits in the "master" branch to GitHub
# 推送本地仓库到远程指定的master主分支上


3、创建仓库

登陆github.com账号创建仓库(Create a New Repository)。付费用户可以建私人仓库,一般的免费用户只能使用公共仓库。

4、参考:

Create A Repo

Git命令与Github的使用

两分钟学会在GitHub托管代码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git github mac