zoukankan      html  css  js  c++  java
  • Git常用命令

    本文是Git常用命令速查文档,如果要看命令的具体介绍和使用可以看我Git分类下的其他文章

    Git常用命令:

    所属内容 功能描述 Git 命令
    版本库文件管理 把本地目录变成Git可管理的仓库 $ git init
      将文件或者修改添加到仓库 $ git add <filename>
    $ git commit -m "<description>"
       
      从版本库中删除文件 $ git rm <filename>
    $ git commit -m "<description>"
      撤销暂存区的修改 $ git reset HEAD <filename>
      丢弃工作区的修改 $ git checkout -- <filename>
      回退到某个版本 $ git reset --hard HEAD^        or        $ git reset --hard <commitid>
    查看状态和记录 查看版本库状态 $ git status
      查看本地文件和仓库文件的不同 $ git diff <filename>
      查看修改记录 $ git log      or        $ git log --pretty=oneline
      查看分支合并情况 $ git log --graph --pretty=oneline --abbrev-commit
       
      把分叉的提交历史整理成一条直线 $ git rebase 
    $ git log --graph --pretty=oneline --abbrev-commit
    分支管理 查看分支  $ git branch 
      创建并切换分支  $ git checkout -b   <branchname>        or        $ git branch <branchname>
                                                                         $ git checkout <branchname>
      合并分支到当前分支 $ git merge <branchname>        or        $ git merge --no-ff -m "description" <branchname>
      删除分支 $ git branch -d <branchname>
    远程库 首次把本地库推送到远程库(github) $ git remote add origin   <githubrepositoryaddress>
    $ git push -u origin master
      从远程库(github)克隆到本地 $ git clone <githubrepositoryaddress>
      查看远程库信息 $ git remote        or        $ git remote -v
      推送分支 $ git push origin <branchname>
      抓取分支 $ git branch --set-upstream-to=origin/<remotebranchname> <localbranchname>
    $ git pull
    工作现场管理 储藏工作现场 $ git stash 
      查看工作现场 $ git stash list
      恢复工作现场并删除 $ git stash pop        or         $ git stash apply <stashname>
                                             $ git stash drop <stashname>
    标签管理 创建标签
       
    $ git tag <tagname>        or        $ git tag <tagname> <commitid>        or        $ git tag -a <tag name> -m "<description>" <commitid>
      查看所有标签 $ git tag 
      查看标签信息 $ git show <tagname>
      删除标签 $ git tag -d <tagname>
      推送标签到远程 $ git push origin <tagname>        or        $ git push origin --tags
      删除远程标签 $ git tag -d <tagname>
    $ git push origin :refs/tags/<tagname>
    Git自定义 让Git显示颜色 $ git config --global color.ui ture 
      给Git命令配置别名 $ git config --global alias.<alias> <fullname>
  • 相关阅读:
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standard
    mybatis plus 代码生成器
    ServerU FTP服务器无法上传中文名文件怎么办
    关于java文件下载文件名乱码问题解决方案
    使用Redis模拟简单分布式锁,解决单点故障的问题
    springboot定时任务处理
    AtomicInteger类的理解与使用
    java队列——queue详细分析
    ABAP DEMO so批量导入
    ABAP DEMO ole示例程序
  • 原文地址:https://www.cnblogs.com/AmyHu/p/9923676.html
Copyright © 2011-2022 走看看