Git 提交前合并的工作流程?

Git workflow for pre-commit merge?

使用 SVN,我遵循的工作流程是:

当我尝试在 Git 中复制此工作流程时,我遇到了可怕的“您对以下文件的本地更改将被合并 覆盖”错误。

将原始更改合并到我的本地副本中以便我可以在提交之前进行验证的步骤是什么?有没有办法像在 SVN 中那样指定合并每个文件并编辑冲突?

你为什么不试试这个?

git add somefile
git commit -m "this will save my local changes"

git pull origin master
#this merges with origin master, if there's a merge error. You can fix it
# and commit again

git push origin master 
#this will push the merge with the remote master

Git 和 SVN 之间的一个区别是 Git 将 "record my changes to the code" 步骤分为两个步骤:提交和推送,而 SVN 只有提交。在 Git 中,冲突的解决发生在提交 之后 ,但在推送 之前 。这意味着这个过程看起来几乎 "opposite" 到 SVN,在那里你更新,然后解决冲突,然后提交。在 Git 中,您想要提交,然后拉取(此时您可以解决冲突),然后推送。