• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
增强的一亩三分地
增强的一亩三分地
博客园          联系   管理     
Git(4)——把文件添加并提交到版本库

把文件添加并提交到版本库


千万不要使用Windows自带的记事本编辑任何文本文件,下载notepad++进行编辑,仅限于windows。
编写一个readme.txt文件,内容如下
Git is a version control system.
Git is free software.
一定要放到learngit目录下(子目录也行),因为这是一个Git仓库,放到其他地方Git再厉害也找不到这个文件。
1. 用命令git add把文件添加到仓库
$ git add readme.txt
2. 用命令git commit把文件提交到仓库
$ git commit -m "wrote a readme file"
[master (root-commit) cb926e7] wrote a readme file
 1 file changed, 2 insertions(+)
 create mode 100644 readme.txt
git commit命令,-m后面输入的是本次提交的说明,可以输入任意内容,当然最好是有意义的,这样你就能从历史记录里方便地找到改动记录。
commit可以一次提交很多文件,所以你可以多次add不同的文件
3. 用命令git status查看版本库的状态
$ git status
On branch master
nothing to commit, working tree clean
posted on 2017-05-09 23:31  -leanard-  阅读(6)  评论(0)    收藏  举报  来源
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3