git和github使用(一)

前端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版本


    查看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 结果
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 本文转载自:使用git和github管理自己的项目---基础操作学习,进行了重新排版。二次转载请注明原作出处。 我...
    mac在路上阅读 2,585评论 0 22
  • 1.git的安装 1.1 在Windows上安装Git msysgit是Windows版的Git,从https:/...
    落魂灬阅读 12,720评论 4 54
  • 我常常会想儿童美术是什么?我们的孩子为什么学画画?这个问题太大太广,每个家长心中的答案都各不相同。带着对艺术...
    静乐园阅读 1,430评论 2 2
  • 每个人都会做梦,梦里是另一个世界,无论好坏。梦里的自己可以无所不能,所向披靡。想象力丰富的人往往梦到的也是千奇百怪...
    茶尤阅读 482评论 3 3
  • 双十二把房子的首付付了,整整一百万。剁手!
    骁龙阅读 46评论 0 0