git 命令

102 阅读1分钟
  • 初始化版本库 git init
  • 添加文件到暂存区 git add filename git commit -m '描述信息'
  • 查看仓库状态
  • git status 查看状态
  • pwd:显示当前所在目录
  • ll:显示下面的文件详情
  • ls -a :把隐藏目录展示出来
  • echo 'git repo2' >> text.txt 追加文本到文件里。
  • cat test.txt: 展示文件的内容

  • git add bash_demo.txt 需求变更提交到暂存区

  • 取消变更的需求 git reset HEAD bash_demo.txt(从暂存区回退)

  • 清空工作区的文件 git checkout -- bash_demo.txt

  • 添加新需求 git add bash_demo.txt

  • 提交仓库 git commit -m '描述'

  • git log 拿到commit号

  • git reset --hard commit号(从本地分支回退)

  • 情况本地文件 gitrm bash_demo.txt


  • 从远程检出新分支 git checkout -b local_lib_name origin/master
  • 删除远程分支
    1. git push origin --delete Chapater6
    2. git push origin :Chapater8
  • 删除本地分支 git branch -d Chapater8

  • 完全舍弃没有提交的改动 $ git reset --hard HEAD