饥人谷技术博客

git和github使用(一)

2015-11-24  本文已影响74人  奔跑的Pi

前端7班_leec

Git是什么##

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

配置Git##

git config --global user.name "<Your Name>"
git config --global user.email "<youremail@example.com>"

Repository##

1.git init
新建文件夹mkdir hello-world,进入到hello-world文件夹,使用命令行:

git init

git init
2.新增(add)和提交(commit)
在hello-world文件夹新建readme.txttouch readme.txt,查看repo状态git status
touch file and check status
用命令git add告诉Git,把文件添加到仓库:

git add readme.txt

用命令git commit告诉Git,把文件提交到仓库:

git commit -m "add a readme file"

add and commit
在readme.txt中添加文字后,用git diff查看自上次commit后之间的变化。
git diff
提交新修改,git commit -m "<your commit message>"
git commit the changed file

github##

上面介绍的只是在本地建立repository,要想分享给别人或者团队合作,我们得把它提交到远程仓库。
1.新建远程仓库

在github上新建repo

2.远程连接(会提示github账号和密码)

远程连接

git remote add origin https://github.com/leechpee/hello-world.git
git push -u origin master

git push

我们就能在自己的github上看到如下结果:

git push 结果
上一篇 下一篇

猜你喜欢

热点阅读