git pull origin开发vs git merge

时间:2018-11-23 07:44:47

标签: git

我已经签出了一项功能,可以开始使用;但是我想用最新的开发来更新它。但是我犯了一个错误,我没有进行“ git pull origin development”,而是看到发生了合并。那样行吗?我可以继续,它类似于“ git rebase”或“ git merge development”?

$git checkout feature/migration
Branch 'feature/migration' set up to track remote branch 'feature/migration' from 'origin'.
Switched to a new branch 'feature/migration'


$git pull origin develop
From https://github.com/xxx
 * branch              develop    -> FETCH_HEAD
Auto-merging web/package.json
Auto-merging package.json
Merge made by the 'recursive' strategy.
 api/src/entity/User.ts            |  8 ++++++ ... more

我做了

git reset --hard  619c69ae

重置前记录

$git lg1
*   18ee4066 - (2 minutes ago) Merge branch 'develop' of https://github.com/proj into feature/migration - Dave (HEAD -> feature/migration)
|\  
| *   619c69ae - (16 hours ago) Merge branch 'release/3.1.64' into develop - Dave (origin/develop, origin/HEAD, develop)
| |\  
* | | e8491f6e - (3 days ago) fix delete index - Dave (origin/feature/migration)

重置后glog

*   619c69ae - (16 hours ago) Merge branch 'release/3.1.64' into develop - Dave (HEAD -> develop, origin/develop, origin/HEAD, feature/migration)
|\  
| | *   eaa8f62a - (16 hours ago) Merge branch 'release/3.1.64' - Dave (tag: 3.1.64, origin/master, master)
| | |\  
| | |/  
| |/|   
| * | 2dda35ad - (16 hours ago) release 3.1.64 - Dave
|/ /

2 个答案:

答案 0 :(得分:0)

可以。我们可以粗略地说git pull = git fetch + git merge

此外,有时git rebase can cause disasters,因此您可以考虑使用合并而不是重新设置基准。

但是,git rebasegit merge可以是different point of view for histories

答案 1 :(得分:0)

您可以继续进行开发。 但是无论如何,rebasemerge之间的主要区别是

  • 通过消除不必要的合并提交并以划线员顺序重写历史记录,您可以从rebase获得更清晰的项目历史记录。

如果您仍然想返回并尝试rebase

撤消合并

git reset --hard ORIG_HEAD

然后重新设置

git rebase develop