git将代码提交错了分支
参考
git把功能开发错了分支莫慌
如何在 Git 里撤销(几乎)任何操作和log、reflog、cherry-pick使用
步骤
git checkout 不该提交代码提交了代码的分支
git reset 某次提交哈希值 (git reset HEAD~1 最近一次提交放回暂存区, 并取消此次提交)
git add . 将文件提交到暂存区
git stash (把暂存的文件提交到git的暂存栈)
git checkout 该提交代码的分支
- git stash pop
正常提交代码即可
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug|REVERTING)
$ git log --graph
* commit bd38a09b2c1983eba834330db524b69dbd397d37 (HEAD -> pc_bug)
| Author: xiechangzhou
| Date: Fri Feb 14 09:54:09 2020 +0800
|
| 到分则所有都加时间条件 味遇pc日结添加服务员数据统计
|
* commit 4b568e086019bcd93e27e490b4b94d588d17b7fc
| Author: xiechangzhou
| Date: Thu Feb 13 21:41:45 2020 +0800
|
| 味遇pc日结添加服务员数据统计 修改xml
|
* commit f8cea85a01e66a2e47c29245ed9677d8f48fe4bb
| Author: xiechangzhou
| Date: Thu Feb 13 21:32:15 2020 +0800
|
| 味遇pc日结添加服务员数据统计
|
* commit 8d268344dc113b74f2b669b32f871a9c3f8195b0 (origin/pc_bug, pc_waiter)
|\ Merge: 7bac039 c65bff6
| | Author: zhaomeng <62672000>
| | Date: Thu Feb 6 21:05:17 2020 +0800
| |
| | Merge branch 'pc_bug' of http://114.215.104.72:8888/weiyu/handordering into pc_bug
| |
| * commit c65bff626cc37f89798390e142e0098a48024e65
| |\ Merge: 8296c3d b147bab
| | | Author: zhanglan
| | | Date: Thu Feb 6 20:29:25 2020 +0800
| | |
| | | Merge remote-tracking branch 'origin/pc_bug' into pc_bug
| | |
| | * commit b147bab58a606a912db89fc23fbb4fd4dd7422d0
| | | Author: xiechangzhou
| | | Date: Thu Feb 6 20:25:46 2020 +0800
| | |
| | | 订单详情退款人展示退款人姓名
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug|REVERTING)
$ git branch -a
master
* pc_bug
pc_waiter
produce
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/pc_bug
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug|REVERTING)
$ git reset 8d268344dc11
Unstaged changes after reset:
M src/main/java/com/zichen/pc/util/TableUtil.java
M src/main/java/com/zichen/xhkq/dao/order/OrderStatisticsDao.java
M src/main/java/com/zichen/xhkq/dict/publicflag/Dict_tabel.java
M src/main/java/com/zichen/xhkq/mapping/ordermanage/OrderStatisticsMapping.xml
M src/main/java/com/zichen/xhkq/service/order/OrderStatisticsService.java
M src/main/java/com/zichen/xhkq/vo/DailySettlementByMinutesVO.java
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug)
$ git status
On branch pc_bug
Your branch is up-to-date with 'origin/pc_bug'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: src/main/java/com/zichen/pc/util/TableUtil.java
modified: src/main/java/com/zichen/xhkq/dao/order/OrderStatisticsDao.java
modified: src/main/java/com/zichen/xhkq/dict/publicflag/Dict_tabel.java
modified: src/main/java/com/zichen/xhkq/mapping/ordermanage/OrderStatisticsMapping.xml
modified: src/main/java/com/zichen/xhkq/service/order/OrderStatisticsService.java
modified: src/main/java/com/zichen/xhkq/vo/DailySettlementByMinutesVO.java
Untracked files:
(use "git add ..." to include in what will be committed)
src/main/java/com/zichen/pc/model/bo/TableName.java
src/main/java/com/zichen/pc/model/vo/WaiterPerformanceVO.java
src/test/myTest/pc/
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug)
$ git stash
Saved working directory and index state WIP on pc_bug: 8d26834 Merge branch 'pc_bug' of http://114.215.104.72:8888/weiyu/handordering into pc_bug
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug)
$ git status
On branch pc_bug
Your branch is up-to-date with 'origin/pc_bug'.
Untracked files:
(use "git add ..." to include in what will be committed)
src/main/java/com/zichen/pc/model/bo/TableName.java
src/main/java/com/zichen/pc/model/vo/WaiterPerformanceVO.java
src/test/myTest/pc/
nothing added to commit but untracked files present (use "git add" to track)
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_bug)
$ git checkout pc_waiter
Switched to branch 'pc_waiter'
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git stash pop
On branch pc_waiter
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: src/main/java/com/zichen/pc/util/TableUtil.java
modified: src/main/java/com/zichen/xhkq/dao/order/OrderStatisticsDao.java
modified: src/main/java/com/zichen/xhkq/dict/publicflag/Dict_tabel.java
modified: src/main/java/com/zichen/xhkq/mapping/ordermanage/OrderStatisticsMapping.xml
modified: src/main/java/com/zichen/xhkq/service/order/OrderStatisticsService.java
modified: src/main/java/com/zichen/xhkq/vo/DailySettlementByMinutesVO.java
Untracked files:
(use "git add ..." to include in what will be committed)
src/main/java/com/zichen/pc/model/bo/TableName.java
src/main/java/com/zichen/pc/model/vo/WaiterPerformanceVO.java
src/test/myTest/pc/
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (d0f16b65f101073cdada906e4c3100d4e28aa178)
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git branch -a
master
pc_bug
* pc_waiter
produce
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/pc_bug
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git status
On branch pc_waiter
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: src/main/java/com/zichen/pc/util/TableUtil.java
modified: src/main/java/com/zichen/xhkq/dao/order/OrderStatisticsDao.java
modified: src/main/java/com/zichen/xhkq/dict/publicflag/Dict_tabel.java
modified: src/main/java/com/zichen/xhkq/mapping/ordermanage/OrderStatisticsMapping.xml
modified: src/main/java/com/zichen/xhkq/service/order/OrderStatisticsService.java
modified: src/main/java/com/zichen/xhkq/vo/DailySettlementByMinutesVO.java
Untracked files:
(use "git add ..." to include in what will be committed)
src/main/java/com/zichen/pc/model/bo/TableName.java
src/main/java/com/zichen/pc/model/vo/WaiterPerformanceVO.java
src/test/myTest/pc/
no changes added to commit (use "git add" and/or "git commit -a")
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git add .
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git status
On branch pc_waiter
Changes to be committed:
(use "git reset HEAD ..." to unstage)
new file: src/main/java/com/zichen/pc/model/bo/TableName.java
new file: src/main/java/com/zichen/pc/model/vo/WaiterPerformanceVO.java
modified: src/main/java/com/zichen/pc/util/TableUtil.java
modified: src/main/java/com/zichen/xhkq/dao/order/OrderStatisticsDao.java
modified: src/main/java/com/zichen/xhkq/dict/publicflag/Dict_tabel.java
modified: src/main/java/com/zichen/xhkq/mapping/ordermanage/OrderStatisticsMapping.xml
modified: src/main/java/com/zichen/xhkq/service/order/OrderStatisticsService.java
modified: src/main/java/com/zichen/xhkq/vo/DailySettlementByMinutesVO.java
new file: src/test/myTest/pc/WaiterTest.java
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git commit -m 收银员统计
[pc_waiter 973d690] 收银员统计
9 files changed, 305 insertions(+), 20 deletions(-)
create mode 100644 src/main/java/com/zichen/pc/model/bo/TableName.java
create mode 100644 src/main/java/com/zichen/pc/model/vo/WaiterPerformanceVO.java
create mode 100644 src/test/myTest/pc/WaiterTest.java
jie@mozq MINGW64 /d/00/mozq_pro1/handordering2 (pc_waiter)
$ git log --graph --all
* commit 973d6903c1a165b91fe549f9d20756274ba30e56 (HEAD -> pc_waiter)
| Author: xiechangzhou
| Date: Tue Feb 18 11:48:50 2020 +0800
|
| 收银员统计
|
* commit 8d268344dc113b74f2b669b32f871a9c3f8195b0 (origin/pc_bug, pc_bug)
|\ Merge: 7bac039 c65bff6
| | Author: zhaomeng <62672000>
| | Date: Thu Feb 6 21:05:17 2020 +0800
| |
| | Merge branch 'pc_bug' of http://114.215.104.72:8888/weiyu/handordering into pc_bug
| |
| * commit c65bff626cc37f89798390e142e0098a48024e65
| |\ Merge: 8296c3d b147bab
| | | Author: zhanglan
| | | Date: Thu Feb 6 20:29:25 2020 +0800
| | |
| | | Merge remote-tracking branch 'origin/pc_bug' into pc_bug
| | |
| | * commit b147bab58a606a912db89fc23fbb4fd4dd7422d0
| | | Author: xiechangzhou
| | | Date: Thu Feb 6 20:25:46 2020 +0800
| | |
| | | 订单详情退款人展示退款人姓名