zoukankan      html  css  js  c++  java
  • git 学习(一)初始化和提交

    git 学习(一)

    创建git版本库
    $ mkdir gitstudy
    $ cd gitstudy
    $ git init
    nitialized empty Git repository in /Users/fengxi/Documents/gitstudy/.git/
    

    新建一个文件

    $ vim
    good git
    git is a file version control system
    :w readme.txt
    :q
    

    查看文件

    $ ls
    readme.txt
    

    提交文件

    $ git add readme.txt
    $ git commit -m "create readme.txt file"
    [master (root-commit) 69a629d] create readme.txt file
    1 file changed, 2 insertions(+)
    create mode 100644 readme.txt	
    

    修改文件

    $vim
    :open readme.txt
    good git
    git is a file version control system
    good good study //新添加的
    :wq
    

    查看状态

    $ git status
    On branch master
    Changes not staged for commit:
    (use "git add <file>..." to update what will be committed)
    (use "git checkout -- <file>..." to discard changes in working directory)
    
    modified:   readme.txt
    
    no changes added to commit (use "git add" and/or "git commit -a")
    

    修改内查询

    $ git diff readme.txt
    diff --git a/readme.txt b/readme.txt
    index 058f007..7550558 100644
    --- a/readme.txt
    +++ b/readme.txt
    @@ -1,2 +1,3 @@
    good git
    git is a file version control system
    +good good study	
    

    提交修改

    $ git add readme.txt
    

    提交前检查

    $ git status
    On branch master
    Changes to be committed:
    (use "git reset HEAD <file>..." to unstage)
    
    modified:   readme.txt
    

    git提醒我们readme.txt将会被提交

    提交

    $ git commit -m "add good study"
    [master 148ff70] add good study
    1 file changed, 1 insertion(+)
    

    提交后再次查看

    $ git status
    On branch master
    nothing to commit, working directory clean
    

    工作目录已经干净了全部都已经提交

  • 相关阅读:
    webpack 入门(1)入口(entry)出口(output
    npm 常用使用命令
    typora快捷键
    一些思考
    SED LEARN NOTE
    常用网站工具整理
    DFTC
    Notion使用技巧
    BASH LEARN NOTE
    STBC公式
  • 原文地址:https://www.cnblogs.com/keithmoring/p/4223037.html
Copyright © 2011-2022 走看看