git push 后合并之前的commit
2014-03-31 11:16
671 查看
原文:点击打开链接
referer url: http://stackoverflow.com/questions/5189560/how-can-i-squash-my-last-x-commits-together-using-git
FOR EXAMPLE:
I have 3 commits in history:
commit 1: #3333 zzzzzz
commit 2: #2222 yyyyyy
commit 3: #1111 xxxxxx
NOW, I want to squash last 2 commits
Step 1:
then the output like this:
Step 2:
then the output like this:
Step 3:
OUTPUT:
Step 4:
OUTPUT:
if push get errors, you need to force push:
OUTPUT:
Merge or squash commits in git after pushed
referer url: http://stackoverflow.com/questions/5189560/how-can-i-squash-my-last-x-commits-together-using-gitFOR EXAMPLE:
I have 3 commits in history:
commit 1: #3333 zzzzzz
commit 2: #2222 yyyyyy
commit 3: #1111 xxxxxx
NOW, I want to squash last 2 commits
Step 1:
$ git reset --hard HEAD~2
then the output like this:
HEAD 现在位于 4cf49a1 #255 斗金绿色平台开发者列表可以按照选择拓展人员查看对应开发者列表
Step 2:
$ git merge --squash HEAD@{1}
then the output like this:
更新 4cf49a1..399379d Fast-forward 压缩提交 -- 未更新 HEAD Controller/0000Controller.php | 65 +++++++++++++++++++++++++ Controller/111111Controller.php | 22 ++++++++- Model/33333.php | 78 +++++++++++++++++++++++++++++- View/44444/5555.ctp | 10 +++- View/4444/666666.ctp | 41 ++++++++++++++++ webroot/js/44444/xxxxx.js | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 View/aaaa/xxx.ctp create mode 100644 webroot/js/aaaa/bbbb.js
Step 3:
$ git commit -m "#255 aaaaaa"
OUTPUT:
[master 8f35d2d] #255 aaaaaa 6 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 View/aaaa/bbbb.ctp create mode 100644 webroot/js/aaaa/bbbb.js
Step 4:
$ git push
OUTPUT:
To git@git.xxxx.net:xxxx/bbbb.git ! [rejected] master -> master (non-fast-forward) error: 无法推送一些引用到 'git@git.umlife.net:xxxx/bbbb.git' 提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。 提示:再次推送前,先与远程变更合并(如 'git pull')。详见 提示:'git push --help' 中的 'Note about fast-forwards' 小节。
if push get errors, you need to force push:
$ git push origin +master
OUTPUT:
Counting objects: 27, done. Delta compression using up to 4 threads. Compressing objects: 100% (15/15), done. Writing objects: 100% (15/15), 4.03 KiB | 0 bytes/s, done. Total 15 (delta 9), reused 0 (delta 0) To git@git.xxxx.net:aaa/xxx.git + 399379d...8f35d2d master -> master (forced update)
相关文章推荐
- git 操作之合并commit(提交之前本地合并)
- git的操作(拉代码到本地/commit到本地/pull/push到远程/新建分支/合并分支/)
- git commit 之后 push 之前,想删除 个别的commit 文件
- git合并分支或者push时,报错:“Please enter a commit message to explain why this merge is necessary,especi”的解决办法
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- git合并分支或者push时,报错:“Please enter a commit message to explain why this merge is necessary,especi”的解决办法
- 02_创建Git仓库,克隆仓库,git add,git commit,git push,git pull,同行冲突,不同行冲突的结局方案,git mergetool的使用
- IDEA中Git分支未push的变更集如何合并到另一个分支
- 【Git】常用命令commit提交,push推送,merge,添加分支branch
- 如何解决无法成功git commit 和git push
- Git操作指南(2) —— Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- git rebase之前需要 commit 才行
- 「Git」合并多个 Commit
- 记录一次操作git 的愚蠢行为(本地代码只 git add 过,没有 commit ,push 过,然后版本回退 导致本地代码丢失)
- 在commit之前撤销git add操作 (undo git add before commit)
- git commit & git push
- Git------Commit和Push的区别
- Git关于pull,commit,push的总结