zoukankan      html  css  js  c++  java
  • git 提交各种情况下的处理方式

    自己总结:
    01.若在提交过程中有冲突,解决冲突后,git add .
    git rebase —continue
    git push for
     
    02.git rebase vs git merge
    git rebase b (合并分支b)
    解决冲突
    git rebase —continue
    git rebase —skip//跳过冲突
    git rebase —absort//取消合并
     
    1,在dev分支开发
    git add .
    git commit -am ''
    git pull —rebase //解决冲突
    git push origin dev:refs/for/dev
     
    2,线上线下测试
    1) mvn debug on jetty
    2) curl -H "***: ***" -H "***: ***"  'http://***/***/***?***=***&***=***'
     
    3,若commit之后想要返回
    git log //查看需要退到哪个commitId之前
    git reset commitId
    git push
     
    若git add . 
    git commit 
    git push
    则几乎是把之前做的所有改动真的全部取消
     
    4,若已经git reset —hard commitId
    回到了上次改动的地方,
    git pull将上次的改动再拉下来
    git revert commitId
    git commit 
    git push
     
    git revert 是生成一个新的提交来撤销某次提交,此次提交之前的commit都会被保留
    git reset 是回到某次提交,提交及之前的commit都会被保留,但是此次之后的修改都会被退回到暂存区
     
    网上搜集的有用的实例:
    A) 回滚add操纵 
    引用
    $ edit                                     (1) 
    $ git add frotz.c filfre.c 
    $ mailx                                    (2) 
    $ git reset                                (3) 
    $ git pull git://info.example.com/ nitfol  (4)
     
    B) 回滚最近一次commit 
    引用
    $ git commit ... 
    $ git reset --soft HEAD^      (1) 
    $ edit                        (2) 
    $ git commit -a -c ORIG_HEAD  (3) 
     
    C) 回滚最近几次commit,并把这几次commit放到叫做topic的branch上去。 
    引用
    $ git branch topic/wip     (1) 
    $ git reset --hard HEAD~3  (2) 
     
    D) 永久删除最后几个commit 
    引用
    $ git commit ... 
    $ git reset --hard HEAD~3   (1)
     
    E) 回滚merge和pull操作 
    引用
    $ git pull                         (1) 
    Auto-merging nitfol 
    CONFLICT (content): Merge conflict in nitfol 
    Automatic merge failed; fix conflicts and then commit the result. 
    $ git reset --hard                 (2) 
    $ git pull . topic/branch          (3) 
    Updating from 41223... to 13134... 
    Fast-forward 
    $ git reset --hard ORIG_HEAD       (4)
     
    F) 在被污染的working tree中回滚merge或者pull 
    引用
    $ git pull                         (1) 
    Auto-merging nitfol 
    Merge made by recursive. 
    nitfol                |   20 +++++---- 
    ... 
    $ git reset --merge ORIG_HEAD      (2)
     
    G) 被中断的工作流程 
    在实际开发中经常出现这样的情形:你正在开发一个大的feature,此时来了一个紧急的bug需要修复,但是目前在working tree中的内容还没有成型,还不足以commit,但是你又必须切换的另外的branch去fix bug。请看下面的例子 
    引用
    $ git checkout feature ;# you were working in "feature" branch and 
    $ work work work       ;# got interrupted 
    $ git commit -a -m "snapshot WIP"                 (1) 
    $ git checkout master 
    $ fix fix fix 
    $ git commit ;# commit with real log 
    $ git checkout feature 
    $ git reset --soft HEAD^ ;# go back to WIP state  (2) 
    $ git reset                                       (3)
     
    (H) Reset单独的一个文件 
    假设你已经添加了一个文件进入index,但是而后又不打算把这个文件提交,此时可以使用git reset把这个文件从index中去除。 
    引用
    $ git reset -- frotz.c                      (1) 
    $ git commit -m "Commit files in index"     (2) 
    $ git add frotz.c                           (3)
     
    (I) 保留working tree并丢弃一些之前的commit 
    假设你正在编辑一些文件,并且已经提交,接着继续工作,但是现在你发现当前在working tree中的内容应该属于另一个branch,与这之前的commit没有什么关系。此时,你可以开启一个新的branch,并且保留着working tree中的内容。 
    引用
    $ git tag start 
    $ git checkout -b branch1 
    $ edit 
    $ git commit ...                            (1) 
    $ edit 
    $ git checkout -b branch2                   (2) 
    $ git reset --keep start                    (3) 
  • 相关阅读:
    poj 2362 Square (dfs+剪枝)
    三种素数筛法汇总
    2009’河北省高教网络技能大赛一网站建设部分
    寒假每一天
    寒假每一天
    寒假每一天
    寒假每一天
    统计文本文件
    寒假每一天
    寒假每一天
  • 原文地址:https://www.cnblogs.com/jiangxiaoyaoblog/p/5630889.html
Copyright © 2011-2022 走看看