日度归档:2020年11月4日

git代码仓库常用命令集

  1. 查看当前状态 git status,查看当前哪些代码未提交,及文件修改状态
    yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git status
    On branch developer
    Changes not staged for commit:
     (use "git add/rm <file>..." to update what will be committed)
     (use "git restore <file>..." to discard changes in working directory)
           modified:   .eslintrc.js
           modified:   package.json
           modified:   src/App.vue
           deleted:    src/components/HelloWorld.vue
           modified:   src/main.js
           modified:   src/plugins/element.js
           modified:   src/router/index.js
           deleted:    src/views/About.vue
           deleted:    src/views/Home.vue
           modified:   yarn.lock
    
    Untracked files:
     (use "git add <file>..." to include in what will be committed)
           src/components/home.vue
           src/components/login.vue
           vue.config.js
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
  2. 查看分支 git branch
    yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git branch
    * developer
     master
    
  3. 添加文件 git add .,如果添加单个文件后面跟文件名,如果添加所有文件使用通配符.
    yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git add .
    yusian@Work-SianMac:~/Documents/Project/Vue/demo34% git status
    On branch developer
    Changes to be committed:
     (use "git restore --staged <file>..." to unstage)
           modified:   .eslintrc.js
           modified:   package.json
           modified:   src/App.vue
           deleted:    src/components/HelloWorld.vue
           new file:   src/components/home.vue
           new file:   src/components/login.vue
           modified:   src/main.js
           modified:   src/plugins/element.js
           modified:   src/router/index.js
           deleted:    src/views/About.vue
           deleted:    src/views/Home.vue
           new file:   vue.config.js
           modified:   yarn.lock
    

    继续阅读