git_vs_github入门

来源:互联网 发布:java extends super 编辑:程序博客网 时间:2024/06/01 10:44

1.概念

git和github相当于svn和goole code,我们用eclipse svn 提交到google code发起开源项目,其实git和github也是这样一种情况.

git没有中央仓库的这种概念,只是一台服务器装了git ,其他人往这个服务器上面commit文件。


2.工具

windows git工具:

TortoiseGit , Git-1.8.3-preview20130601,

一般我们用安装后Git-1.8.3-preview20130601

会有终端界面和图形界面.



在这里相当于和linux终端一样,可以输入命令

分三步 走:

先设置基本信息,用户和邮箱

git config --global user.name "Your Name Here“
git config --global user.email "your_email@example.com“

1.git init (相当于工具的的初始化新建个仓库)

2.git add filename

3.git commit (带参数-m填写描述)

当然得用随时查看状态 git status

和查看日志看有没有提交上去  git log


git本地和github官网的检出检入

a.在官网新建个仓库 (New Respository)查看帮助文档(https://help.github.com/articles/create-a-repo)

b.新建后会有个地址,把地址Copy

c.本地生成SSH公钥和密钥.(SSH),和linux上面的SSH一样的原理

cd ~/.ssh

ssh-keygen -t rsa -C "your_email@example.com” (测试邮箱)

具体生成公钥和密钥可以参考 (https://help.github.com/articles/generating-ssh-keys)

将id_rsa.pub公钥里面的内容添加到gitHub中的Setting 中的SSH里面

将github里面的检出可以用客户端工具或者eclipse,直接将地址复制下来就可以

checkout到本地 :git clone git@github.com:leroyhzy/leroyTest01.git

提交时可以查看远程地址; git remote -v

提交到github git push origin master


原创粉丝点击