新 push 了一个功能,后来发现暂时不能 merge 。现在需要退回到几个 commit 之前,但是不能丢掉这几个 commit ,之后应该还能用到。用 revert 还是 reset?
新 push 了一个功能,后来发现暂时不能 merge 。现在需要退回到几个 commit 之前,但是不能丢掉这几个 commit ,之后应该还能用到。用 revert 还是 reset?
|
cevincheungApr 13, 2016
1
开分支
|
|
cevincheungApr 13, 2016
2
先备份现在代码,回滚版本。开分支,应用新代码。啥时候 merge 啥时候再合并本地两个分支。
|
|
3
@cevincheung thx. checkout 之前的 commit, 转到新的 branch 。
|
|
clinoApr 13, 2016 via Android
4
将代码提交到一个临时分支 之后随便折腾
|
|
RoshanWuApr 13, 2016 via iPhone
5
git reset 提交点
git stash git checkout -b 新分支 开发新功能 在任意时间节点想应用回原先修改部分: git stash pop 如要放弃原先修改部分: git stash drop |
|
rwechoApr 13, 2016
6
stash
|
|
v1024Apr 13, 2016
7
用 SourceTree 的话,可以在需要回退到的 commit 上点分支,就会从那个位置新建一个分支,现在的代码还在当前分支上就好。
|
|
yxzblueApr 13, 2016
8
git reset --soft
|
|
restranApr 13, 2016
9
利用 git reflog 可以找到所有操作的提交点,即便是直接 git reset 到提交点,这之间的所有 commit 也都还是能回退回去的。可以看看聊雪峰的 Git 教程,版本回退那一章。如果你用 TortoiseGit 可以看看 http://www.restran.net/2016/02/22/git-recovery/
|
|
msg7086Apr 13, 2016
10
当前提交上新建 Feature 分支,然后把主干分支 reset 回去就好了。
|
|
flowfireApr 13, 2016
11
直接 reset 就好。。。。因为即使 reset 了。现有版本并没有被删除。。。
|
|
bomblessApr 13, 2016 via Android
12
git branch 备份分支名
git reset --hard 之前的某个提交 git push -f |
|
VicYuApr 13, 2016
13
git stash
git reset |
|
jsonlineApr 13, 2016
14
branch 吧
|
|
yoa1q7yApr 13, 2016
15
好多人真的不会用 git...
|
|
yoa1q7yApr 13, 2016
16
8 楼正确答案
|
|
wweirApr 13, 2016
17
git rebase old_commit
|
|
jackisnotspirateApr 13, 2016
18
git rebase
|