您的位置:首页 > 运维架构 > Shell

Git学习日记1

2014-07-15 22:59 176 查看
下载Git:http://download.csdn.net/detail/shengshengwang/7639357

一. 注册GitHub账号

二. 创建仓库

说明:填写项目相关信息。点击Create repository,得到项目地址https://github.com/1000sprites/xxx.git。

三. 安装Git

Git Bash的默认路径是“/c/Users/xxx”,其中xxx表示你电脑用户的名字。

四. 配置Git

1. 本地创建ssh key

ssh-keygen -t rsa -C "your_email@youremail.com"

说明:一路回车,在“/c/Users/xxx”下生成.ssh文件夹。

2. 配置GitHub

回到GitHub,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填写,粘贴key。

说明:key就是.ssh文件夹下id_rsa.pub里面的内容。

3. 验证是否成功

ssh -T git@github.com




说明:
(1)输入yes,忽略警告。

(2)出现以上信息表示配置成功,即Git已经连接上GitHub了。

4. 配置name和email

git config --global user.name "your name"
git config --global user.email "your_email@youremail.com"


五. 克隆项目

git clone https://github.com/1000sprites/matlab_program.git[/code] 


六. 配置远程地址

git remote add origin git@github.com/1000sprites/matlab_program.git

说明:如果报错,则输入git remote rm origin。如果还报错,则输入git init。

七. 提交上传

首先将项目放入“/c/Users/xxx/matlab_program”文件夹下,然后输入如下命令。

git add .
git commit -m 'first_commit'
git push origin master




说明:

(1)特别注意输入命令的路径,此处为项目的路径。

(2)输入GitHub的账号和密码。

(3)执行git push origin master时报错,则执行git pull origin master。 

注意:最后在“/c/Users/xxx”文件夹下,有两个文件夹,分别是.ssh和xxx。有两个文件,分别是.bash_history

和.gitconfig。

参考文献:

[1] github简单使用教程:http://wuyuans.com/2012/05/github-simple-tutorial/

[2] GitHub当道,菜鸟也为Git疯狂:http://www.tuicool.com/articles/qiUb6z

[3] 深入学习:Windows下Git入门教程:http://blog.csdn.net/huangyabin001/article/details/35557231
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  github git shell code windows