Search code examples
gitmerge-conflict-resolution

Git Dealing with merge conflict with tracked and untracked files


I am in this develop branch and i checkout to new local branch to develop new feature.

git checkout -b task-change-title-and-styling

Then now i do some code changes and now i have both tracked and untrack files.

My common practices where i know there wouldn't be a merge conflict are as following:

git add .
git commit -m "Change titles and styling on homepage"
git fetch origin
git rebase origin/develop
git push -u origin task-change-title-and-styling

Done.

Now in new situation where i know my changes will conflict with other, what should i do (assume that i have both tracked and untracked files)?

Following is just my assumption to deal with merge conflict, but not sure whether the steps are correct

git add .
git commit -m "Change titles and styling on homepage"
git fetch origin
git rebase origin/develop

*at this point i assume my git will have merge conflict message*

Then i fix my merge conflicts, then i do

git add .
git rebase --continue
*there are still conflict message*

Fix my codes again, then do

git add .
git rebase --continue
*now no more merge conflict message*
git push -u origin task-change-title-and-styling  

Solution

  • Your assumption is correct. Although, I never use git fetch origin before rebase, because git rebase origin/develop already does pulling of the newest version of develop branch.