【推薦】git經常使用命令

  1. 建立一個新倉庫html

    ➜  h5  mkdir o-knowme
     ➜  h5  cd o-knowme
     ➜  o-knowme  git init
     Initialized empty Git repository in /Users/chenliying/Documents/workspace/h5/o-knowme/.git/
     ➜  o-knowme git:(master) touch README.md
     ➜  o-knowme git:(master) ✗ touch meta.json
     ➜  o-knowme git:(master) ✗ git add .
     ➜  o-knowme git:(master) ✗ git commit -m'first commit'
     [master (root-commit) 919ca41] first commit
      3 files changed, 6 insertions(+)
      create mode 100644 .gitignore
      create mode 100644 README.md
      create mode 100644 meta.json
     ➜  o-knowme git:(master) git remote add origin git@gitlab.pengpeng.la:html5/o-knowme.git
     ➜  o-knowme git:(master) git push -u origin master
     Counting objects: 4, done.
     Delta compression using up to 4 threads.
     Compressing objects: 100% (2/2), done.
     Writing objects: 100% (4/4), 313 bytes | 0 bytes/s, done.
     Total 4 (delta 0), reused 0 (delta 0)
     To git@gitlab.pengpeng.la:html5/o-knowme.git
      + [new branch]      master -> master
     Branch master set up to track remote branch master from origin.
  2. 查看遠程狀況html5

    ➜  module git:(master) git remote -v
      origin  git@gitlab.pengpeng.la:html5/module.git (fetch)
      origin  git@gitlab.pengpeng.la:html5/module.git (push)
  3. 現有倉庫clonegit

    h5  git clone git@gitlab.pengpeng.la:html5/mpt-core.git
  4. 查看倉庫狀態json

    git status
  5. 切換分支gitlab

    ➜  o-mpt git:(master) git checkout daily/1.0.0
      Switched to branch 'daily/1.0.0'
  6. 查看所有分支fetch

    ➜  o-knowme git:(master) git branch -la
      * master
      remotes/origin/master
  7. 刪除本地分支spa

    ➜  o-knowme git:(master) git branch -D la
      Deleted branch la (was 1eb39de).
  8. 刪除遠程分支code

    $ git push origin --delete daily/1.0.0
  9. 查看taghtm

    ➜  o-mpt git:(master) git tag
      publish/1.0.0
  10. add 並提交所有文件rem

    ➜  o-knowme git:(master) ✗ git commit -am'meta.json'
      [master 1eb39de] meta.json
      1 file changed, 14 insertions(+)
  11. 將更改數據推送到遠程倉庫

    ➜  o-knowme git:(master) git push origin master
  12. 刪除本地tag

    ➜  frame git:(master) git tag -d publish/1.0.5
  13. 刪除遠程tag

      ➜  frame git:(master) git push origin --delete tag publish/1.0.5

相關文章
相關標籤/搜索