Git collaborative development method 1:
1. git commit, submit the changes to the git local Cache;
2. git pull --rebase origin branchname, merge the code by rebase;
3. git push -u origin branchname, submit all modifications to the remote end.
This method is suitable for the situation that after all the code is committed, others can compile and run smoothly.
Step 2 may produce file conflicts.
E.g:
Auto-merging products/xxx/res/ccb/Node.ccbi
CONFLICT (content): Merge conflict in products/xxx/res/ccb/Node.ccbi
The modification method is:
1) Manually modify the conflict file;
2) Replace conflicting files with local or other people's files. ( Note: the actual effect of ours/theirs is the opposite of the literal meaning!!! )
a. The local file shall prevail: git checkout --theirs products/xxx/res/ccb/Node.ccbi. (The option will keep the original one we had.)
b. The files submitted by others shall prevail: git checkout --ours products/xxx/res/ccb/Node.ccbi. (The option will keep the version of the file that you merged in.)
After fixing, execute the command:
git add products/xxx/res/ccb/Node.ccbi
git rebase --continue
Repeat the above method until the end of the rebase.
In the middle if the following conditions exist
Applying: Fixed unit test No changes - did you forget to use 'git add'? If there is nothing left to stage, chances are that something else already introduced the same changes; you might want to skip this patch. When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".
In this case, it is likely that the way you repair products/xxx/res/ccb/Node.ccbi is to copy it from elsewhere, instead of manually repairing the conflict , so the system thinks that the file has not changed. The workaround is as follows:
Excuting an order:
git config --global core.trustctime false
Or modify it manually. Reference article .
If the local repair is temporarily unable to commit, you can use stash to update other people's code.
1、git stash --include-untracked
2、git pull --rebase origin branchname
3、git stash pop
4. Fix possible merge file conflicts.
采用git pull --rebase,而不是默认的git merge,请参考文章。