githut入门
1、配置git 环境windows git
进入git shell
1)首先在本地创建ssh key;
E:\GitHub\bonnierep [master]> ssh-keygen -t rsa -C "yourEmail@yourEmail.com"
其中,"yourEmail@yourEmail.com" 填写的是你自己的邮箱地址;之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。
2)回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key。为了验证是否成功,在git shell下输入:
E:\GitHub\bonnierep [master]> ssh -T git@github.com
如果是第一次的会提示是否continue,输入yes就会看到:You've successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。
3)设置username和email,因为github每次commit都会记录他们
E:\GitHub\bonnierep [master]>git config --global user.name "your name"
E:\GitHub\bonnierep [master]>git config --global user.email "yourEmail@yourEmail.com"
4)进入要上传的仓库,右键git bash,添加远程地址:我这里已经在操作的仓库中了
E:\GitHub\bonnierep [master]>git remote add origin git@github.com:yourName/yourRepo.git
yourName和yourRepo表示你再github的用户名和刚才新建的仓库,加完之后进入.git,打开config,这里会多出一个remote “origin”内容,这就是刚才添加的远程地址,也可以直接修改config来配置远程地址。
5)提交与上传:
i.添加文件
E:\GitHub\bonnierep [master]>git add filename
其中文件名filename包括文件后缀名
ii.提交与注释:
E:\GitHub\bonnierep [master]>git commit -m "first commit"
iii.上传到github:
E:\GitHub\bonnierep [master]>git push origin master
git push命令会将本地仓库推送到远程服务器;git pull命令则相反。
修改完代码后,使用git status可以查看文件的差别,使用git add 添加要commit的文件,也可以用git add -i来智能添加文件。之后git commit提交本次修改,git push上传到github
6)gitignore文件
告诉git需要忽略的文件;
——————————————————————————————————————————————————————————————————————————————
资料:
http://git.oschina.net/progit/
http://www.cnblogs.com/ruofengzhishang/p/3842587.html
http://blog.csdn.net/showhilllee/article/details/27706539