Article Directory
1. Ignore local modification and force pull remote to local
Mainly the document directory in the project, there may be more annotations when you look at it, now the remote document is updated, the local version is useless, you can force it
git fetch --all
git reset --hard origin/dev
git pull
Regarding the order of commit and pull, the order of commit——"pull——"push and pull——"commit——"push, both cases have encountered code conflicts. The solution is as follows:
2. Pull first without commit, select revert or stash depending on the local modification amount
// 场景
同事 有新提交
我 没有pull -> 修改了文件 -> pull -> 提示有冲突
2.1 Small local modifications
If the local modification amount is small, for example, only one line is modified, the following process can be followed
-> revert(把自己的代码取消) -> 重新pull -> 在最新代码上修改 -> [pull确认最新] -> commit&push
2.2 Large amount of local amendments and many conflicts
There are two ways to deal with
-> stash save(把自己的代码隐藏存起来) -> 重新pull -> stash pop(把存起来的隐藏的代码取回来 ) -> 代码文件会显示冲突 -> 右键选择edit conficts,解决后点击编辑页面的 mark as resolved-> commit&push
-> stash save(把自己的代码隐藏存起来) -> 重新pull -> stash pop(把存起来的隐藏的代码取回来 ) -> 代码文件会显示冲突 -> 右键选择resolve conflict -> 打开文件解决冲突 ->commit&push
In addition, since I operate git through IDEA, when the conflict is displayed, I operate on the graphical interface as follows
3. Commit but not push, choose reset or merge directly depending on the local modification amount
// 场景
同事 有新提交
我 没有pull -> 修改了文件 -> commit -> pull -> 提示有冲突
3.1 The amount of modification is small, directly roll back to the uncommitted version (you can choose whether to save local modifications)
If the local modification amount is small, for example, only one line is modified, the following process can be followed
-> reset(回退到未修改之前,选hard模式,把自己的更改取消) -> 重新pull -> 在最新代码上修改 -> [pull确认最新] -> commit&push
ps: In fact, it is possible to adopt a direct merge method, here is mainly to provide an idea based on the principle of avoiding merge as much as possible
3.2 The amount of modification is large, directly merge and then submit (currently commonly used)
-> commit后pull显示冲突 -> 手动merge解决冲突 -> 重新commit -> push