zoukankan      html  css  js  c++  java
  • Git 使用总结

    检出分支或者tag代码:git checkout <localBranchName>/<tag>

    切换检出到本地分支 boot-simple(从远程分支拉取代码):git checkout -b <localBranchName>  origin/<remoteBranchName>

    从远程代码分支(标签)或者本地代码分支(标签)检出代码创建新的分支

      git checkout -b [newBranchName]  [origin/<remoteBranchName> | origin/<tagName>]

           git checkout -b [newBranchName]  [branchName | tagName ]

    从本地仓库当前(分支或者tag)创建新的分支:git branch <newLocalBranchName>、

    删除本地分支:git branch -d <localBranchName>    •   恢复被删除的分支git branch <branch_name> <hash_val>

    删除远程分支:git push -d origin <remoteBranchName> 

    标签:

    可以执行如下命令以创建一个叫做 1.0.0 的标签:
    git tag 1.0.0 1b2e1d63ff
    1b2e1d63ff 是你想要标记的提交 ID 的前 10 位字符。使用如下命令获取提交 ID:
    git log
    你也可以用该提交 ID 的少一些的前几位,只要它是唯一的

    git push origin  [branch_name|tag]

    如果本地分支或者标签都存在1.0.0,git push origin 1.0.0 无法提交。

    查看当前分支日志:git log

    查看本地指定分支日志:git log <localBranchName>

    查看远程分支日志: git log  remotes/origin/<remoteBranchName>(也可用登录远程仓库查看)

    查看回滚或者删除分支(git log上查不到的日志):git reflog

    回滚整个版本:

    git reset --hard tag_name/commit_id/HEAD :回滚到tag_name或者commit-id,将commit-id之后提交的commit都去除,

    如果误操作导致退回到之前的版本,用git log是查不到reset日志,得用git reflog查到reset日志,可以再恢复到现在的版本git reset --hard(具体操作见:https://blog.csdn.net/magiclyj/article/details/81475601)。

    git push -f  remote  <remoteBranchName> 可以强制将远程仓库分支更新为回滚的版本。

    回滚某个文件:

      两种方法:

        1、git checkout  commit_id a.txt ==> git push

        2、git reset commit_id a.txt==>git status(会发现缓存区改变了,工作区没有改变) ==>git commit -m 'reset file xxxx' ==>git checkout  -- a.txt(工作区变了)

    推荐GIT教程:

    https://www.yiibai.com/git

    https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000#0

  • 相关阅读:
    支付宝及时到帐接口使用详解
    简便无刷新文件上传系统
    EyesBaby功能实现之窗口拖拽与缩放功能
    Jquery各行换色 click变色
    纯CSS圆角框3-圆角化图片
    WINFORM自定义皮肤制作(上)
    EyesBaby1.0使用帮助文档
    C#实现小写金额转大写金额
    在winform中运用FusionCharts图表(一)
    第一章、基本的圆角框
  • 原文地址:https://www.cnblogs.com/feibazhf/p/10423747.html
Copyright © 2011-2022 走看看