Git常用命令

来源:互联网 发布:买二手物品的软件 编辑:程序博客网 时间:2024/06/05 11:06
  • 提交更改:

    • git add .

    • git commit -m "comment"

    • git push origin master

  • 删除远端文件:

    • git rm -r --cache .idea/

    • git commit -m "comment"

    • git push origin master

  • 删除远程分支:

    • git branch -r -d origin/branch-name

    • git push origin :branch-name

  • git地址迁移:

    • git clone --bare git@github.com:jzpyoung/project.git

    • git push --mirror git@github.com:jzpyoung/newproject.git

    • rm -rf project.git

    • git clone git@github.com:jzpyoung/newproject.git

  • 版本回退:

    • git reset --mixed HEAD~ // 回退远程,保留本地源码

    • git reset --soft HEAD~ // 回退远程,保留本地add

    • git reset --hard HEAD~ // 回退本地和远程源码

    • git push --force

  • 查看分支: git branch

  • 新建tag : git tag v0.0.1

  • 新建分支: git branch xxx develop

  • 切换分支: git checkout -b develop

  • 合并分支: git merge develop

  • 放弃本地修改: git checkout .

  • 将本地的状态回退到和远程的一样:git reset --hard origin/master

  • 删除本地分支: git branch -d develop

  • 删除在本地的但在远程库中已经不存在的分支: git remote prune origin

0 0
原创粉丝点击